[英]Can't run JUnit 4 test case in Eclipse Android project
I am new to Java and am trying to run a unit test on a class I am writing. 我是Java的新手,我正在尝试对我正在编写的类进行单元测试。 Eclipse (3.5) created the unit test class for me and added Junit4 to my class path. Eclipse(3.5)为我创建了单元测试类,并将Junit4添加到了我的类路径中。
My Class: 我的课:
public class DistanceUtil
{
public static double metersToMiles( double meters )
{
return 0;
}
public static double metersToKilometers( double meters )
{
return 0;
}
}
My unit test: 我的单元测试:
public class DistanceUtilTest {
@Test
public final void testMetersToMiles() {
fail("Not yet implemented"); // TODO
}
@Test
public final void testMetersToKilometers() {
fail("Not yet implemented"); // TODO
}
}
When I right click on the unit test and select run as Junit Test I get the following: 当我右键单击单元测试并选择run as Junit Test时,我得到以下内容:
#
# A fatal error has been detected by the Java Runtime Environment:
#
# Internal Error (classFileParser.cpp:3075), pid=5564, tid=4940
# Error: ShouldNotReachHere()
#
# JRE version: 6.0_17-b04
# Java VM: Java HotSpot(TM) Client VM (14.3-b01 mixed mode windows-x86 )
# An error report file with more information is saved as:
# C:\Users\Giles Roadnight\workspaceAndroid\Cycloid\hs_err_pid5564.log
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
#
Anyone got an idea how I can fix this? 任何人都知道如何解决这个问题?
Thanks 谢谢
Having searched Google for an answer, this looks like it might have something to do with Android development tools. 在Google搜索了答案之后,这看起来可能与Android开发工具有关。
Below are steps taken from this comment thread: 以下是从此评论主题中采取的步骤:
Since Alex Spurling's instructions are no longer valid for Eclipse Juno and the latest Android SDK, it may be useful to give another alternative: 由于Alex Spurling的说明不再适用于Eclipse Juno和最新的Android SDK,因此提供另一种选择可能会有用:
It's a bit of a hassle on small projects, but OTOH it helps to enforce modularity and interface segregation. 这对小型项目来说有点麻烦,但OTOH有助于强化模块化和界面隔离。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.