Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/228.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用AndroidJunit测试应用程序二维码扫描仪。4_Android_Android Studio_Testing_Junit4_Qr Code - Fatal编程技术网

使用AndroidJunit测试应用程序二维码扫描仪。4

使用AndroidJunit测试应用程序二维码扫描仪。4,android,android-studio,testing,junit4,qr-code,Android,Android Studio,Testing,Junit4,Qr Code,我正在尝试为我的MainActivity创建一个测试脚本。这个主类有一个二维码扫描器。此时,我可以在用手机进行测试时扫描二维码,但我希望能够用模拟器完成这项工作。我的二维码中的文本仅包含一个字符串:“start1” 这是我的测试脚本: @Test public void shouldRenderView() throws Exception { rule.launchActivity(new Intent()); onView(withId(R.id.

我正在尝试为我的MainActivity创建一个测试脚本。这个主类有一个二维码扫描器。此时,我可以在用手机进行测试时扫描二维码,但我希望能够用模拟器完成这项工作。我的二维码中的文本仅包含一个字符串:“start1”

这是我的测试脚本:

@Test
    public void shouldRenderView() throws Exception {
        rule.launchActivity(new Intent());


        onView(withId(R.id.textStatus)).check(matches(withText("Inruimen")));

        onView(withId(R.id.scan_btn)).perform(click());
        pressBack();

        Thread.sleep(5000);
        //within this period I scan the code.

        onView(withId(R.id.textStatus)).check(matches(withText("draaien")));
    }

嘿,德克,你找到怎么做了吗?