
其中一些测试有随机的失败倾向,主要是Robotium缺少文本字段,或超时,而不是阅读文本.我正在尝试使用@FlakyTest注释,因此它们会在抛出失败的测试错误之前运行两到三次.但是,注释不起作用,测试在失败后不会重新运行.
以下是我使用注释的方法:
public class Classname extends ActivityInstrumentationTestCase2<HomeActivity>{ @LargeTest @FlakyTest(tolerance=3) public voID testMethod(){ //Here I run my roboitium scripts. }} 然后我从命令行运行它:
adb shell am instrument -w com.jayway.test/androID.test.InstrumentationTestRunner
eclipse和测试的命令行执行都没有考虑到片状测试注释.有没有人看到我试图应用@FlakyTest的错误?
解决方法 我对使用@FlakyTest注释没有任何问题.我整理了一个快速测试案例来测试@FlakyTest和Robotium(v2.2):
public class FlakyTestCase extends ActivityInstrumentationTestCase2<Main> {private static int count = 0;private Solo solo;public FlakyTestCase() { super("com.stackoverflow.example",Main.class);}@OverrIDepublic voID setUp() throws Exception { solo = new Solo(getInstrumentation(),getActivity());}@LargeTest@FlakyTest(tolerance=3)public voID testFlaky(){ Log.e("FlakeyTestCase","Execution Count:" + ++count); solo.assertCurrentActivity(null,Main.class); solo.clickOnText("Doesn't Exist"); Log.e("FlakeyTestCase","Shouldn't make it here");}} LogCat显示以下消息:
Execution Count: 1Execution Count: 2Execution Count: 3
所以@FlakyTest注释肯定是被调用的.测试的(最终)失败显示为:
junit.framework.AssertionFailedError: The text: Doesn't Exist is not found!
从未记录过“不应该在这里”的消息.
因此,据我所知,无论如何,你都没有问过@FlakyTest和Robotium,v2.2如何宣告你的注释或任何问题.
也许您的测试代码的另一部分存在问题?
总结以上是内存溢出为你收集整理的使用Robotium进行Android测试注释全部内容,希望文章能够帮你解决使用Robotium进行Android测试注释所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)