是否有可能拥有类似的东西?无论是与Android/Robotium测试框架或任何其他解决方案是否有可能为Android编写复杂的功能测试?
public void testAll() throws Exception {
test_001_LoginActivity();
test_002_MainActivity();
}
public void test_001_LoginActivity() throws Exception {
startActivity();
test_001_LoginActivity_001_emptyUsername();
test_001_LoginActivity_002_emptyPassword();
test_001_LoginActivity_003_incorrectValues();
test_001_LoginActivity_004_correctValues(); // MainActivity is opened on success
}
public void test_002_MainActivity() throws Exception {
test_002_MainActivity_001_profile();
test_002_MainActivity_002_list();
test_002_MainActivity_003_logout();
}
的想法是有test_001_LoginActivity()
和test_002_MainActivity()
包含所有相应的活动测试,而不活动的娱乐。和这一样的显示结果:
test_001_LoginActivity() - OK
--->test_001_LoginActivity_001_emptyUsername() - OK
--->test_001_LoginActivity_002_emptyPassword() - OK
--->test_001_LoginActivity_003_incorrectValues() - OK
--->test_001_LoginActivity_004_correctValues() - OK
test_002_MainActivity() - NOK
--->test_002_MainActivity_001_profile() - OK
--->test_002_MainActivity_002_list() - NOK
--->test_002_MainActivity_003_logout() - OK
这意味着对于LoginActivity
所有测试均顺利通过; test_002_MainActivity_002_list()
测试失败MainActivity
,但test_002_MainActivity_003_logout()
测试通过了(因为活动不是重建)
我是新来的测试,所以也许我犯错和试验的目的是为一个全新的活动实例被执行总是?
对于解决方案,你的建议,我在日志中只得到一个及格的分数 - 为'testAll'方法。我希望所有测试都以独立标记形式出现 –
hmmm,因此您尝试执行的操作不适合jUnit体系结构,因为它会分开运行所有'测试...'方法并显示结果。当然,testAll中的'test''方法也会运行,但是由您手动执行,它们的结果将与testAll相同,然后testAll内部的这些方法也将独立运行。那么也许可以用assert替代“test ...”前缀?结果将成为testAll的一个,但如果某物失败,您将知道究竟在哪里......或者可能有解决方案,但我不知道它...... – Krzysiek