不能运行JUnit 4测试用例在Eclipse中的Android项目 [英] Can't run JUnit 4 test case in Eclipse Android project
问题描述
我是新来的Java,我试图运行的类我写一个单元测试。 Eclipse的(3.5)创建单元测试类,我和增加Junit4到我的类路径中。
I am new to Java and am trying to run a unit test on a class I am writing. Eclipse (3.5) created the unit test class for me and added Junit4 to my class path.
我的类别:
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
}
}
当我右键单击该单元测试,并选择Run As JUnit测试我得到了以下内容:
When I right click on the unit test and select run as Junit Test I get the following:
#
# 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?
感谢
推荐答案
有谷歌搜索的答案,这看起来像它可能有一些做与Android的开发工具。
Having searched Google for an answer, this looks like it might have something to do with Android development tools.
下面是从<一个采取措施href="http://dtmilano.blogspot.com/2008/11/android-testing-on-android-platform.html?showComment=1263997074397#c7120467719610941624">this评论螺纹:
- 右键单击项目 - >运行 - >运行配置。
- 选择您的Junit项目
- 转到类路径标签
- 删除Android框架条目
- 选择引导条目
- 点击先进
- 选择添加库
- 确定
- 选择了JRE系统库
- 下一步
- 完成
- 您还需要补充,而不是JRE系统库 JUnit的库,以便按照步骤5到11,然后选择的Junit
- 您现在可以运行项目为Junit的。
- Right click on the project -> run -> run configuration
- Select your Junit project
- Go to the classpath tab
- remove the Android framework entry
- select bootstrap entries
- click on advanced
- select Add Library
- Ok
- Chose "JRE System Library"
- Next
- finish
- You need to also add the JUnit library so follow the steps 5 to 11 and select the "Junit" instead of "JRE System Library"
- You can now run your project as Junit.
这篇关于不能运行JUnit 4测试用例在Eclipse中的Android项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!