示例项目"在Android的测试项目和QUOT JUnit 4中获得亚军; [英] Junit 4 runner in android test project "Sample Project"
本文介绍了示例项目"在Android的测试项目和QUOT JUnit 4中获得亚军;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我提供的Android样品测试项目,只有2-3个java文件,通过使用JUnit 4。
我试图做到这一点。
Provide me Android sample test project with only 2-3 java files,by using JUnit 4. I was trying to do this.
我的主要测试文件。
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@RunWith(Suite.class)
@Suite.SuiteClasses({
SimpleMathTest.class
// add other classes here (comma separated)
})
public class TestSuite {
}
和我做了另外一个测试文件作为JUnit 4中,也就是
and I made another test file as JUnit 4 that is
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
public class SimpleMathTest {
@BeforeClass
public static void setUpBeforeClass() throws Exception {
}
@AfterClass
public static void tearDownAfterClass() throws Exception {
}
@Before
public void setUp() throws Exception {
}
@After
public void tearDown() throws Exception {
}
}
但在执行错误显示的时间:
but at the time of execution Error displays:
SampleTest:无法启动测试
SampleTest: Failed to launch test
请给我一些解决方案。
感谢
推荐答案
以下步骤为我工作:
- 创建新的JUnit(而不是Android的JUnit测试)Testconfiguration:
- 添加一个新的测试发射器:
- 选择以下启动:
使用这个配置,我可以运行我的单元测试。他们在PC,而不是在手机上运行。希望这有助于。
With this configuration I can run my unit tests. They run on the pc and not on the phone. Hope this helps.
这篇关于示例项目"在Android的测试项目和QUOT JUnit 4中获得亚军;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文