Android 浓缩咖啡自动测试和手动测试同时进行

Android 浓缩咖啡自动测试和手动测试同时进行,android,testing,manual,android-espresso,Android,Testing,Manual,Android Espresso,我正在为一款通过NFC标签与仪器交互的android应用程序编写浓缩咖啡自动测试。在NFC读取和手动与仪器交互期间,我想暂停浓缩咖啡测试3-4分钟。我们可以在浓缩咖啡测试期间同时进行自动和手动交互吗?闲置资源是否是一种选择,因为暂停期间会有UI更改?好吧,我不想同时进行自动和手动测试,从理论上讲,自动测试应该加快检查用户与应用程序交互的过程,并让手动测试人员从一些工作中解脱出来 在运行自动意大利浓咖啡测试的过程中进行手动测试真是一个坏主意。很容易中断测试或更改应用程序的状态,这将导致测试失败 在

我正在为一款通过NFC标签与仪器交互的android应用程序编写浓缩咖啡自动测试。在NFC读取和手动与仪器交互期间,我想暂停浓缩咖啡测试3-4分钟。我们可以在浓缩咖啡测试期间同时进行自动和手动交互吗?闲置资源是否是一种选择,因为暂停期间会有UI更改?

好吧,我不想同时进行自动和手动测试,从理论上讲,自动测试应该加快检查用户与应用程序交互的过程,并让手动测试人员从一些工作中解脱出来

在运行自动意大利浓咖啡测试的过程中进行手动测试真是一个坏主意。很容易中断测试或更改应用程序的状态,这将导致测试失败

在上一次谷歌测试自动化会议上宣布了2015年-浓缩咖啡测试记录器

在浓缩咖啡中,我看到了三种可能的测试方法:

  • 创建自定义空闲资源类并注册它
  • 使用Java空闲方法,如
    Thread.sleep(240000)
  • 编写所有您想要的自动化测试,并运行它们。终于做到了 选定的手动测试
  • 编辑:根据您的问题,最好使用
    Thead.sleep(毫秒)
    。它将停止测试所需的时间,如3或4分钟

    但浓缩咖啡测试以随机顺序运行,因此请重新配置现有配置,如下所示:

     @RunWith(AndroidJUnit4.class)
     @FixMethodOrder(MethodSorters.NAME_ASCENDING) 
     public class EspressoExampleTest {
    
     @Rule
     public ActivityTestRule<MainActivity> mRule = new ActivityTestRule<>(MainActivity.class);
    
     @Test
     public void checkIfAppNameIsDisplayed() {
         onView(withText(R.string.app_name)).check(matches(isDisplayed()));
     }
    
    build.gradle
    中,在
    android->defaultConfig
    中声明您的
    testInstrumentationRunner
    当然还有浓缩咖啡,因此您的gradle文件应该包含:

    android {
     defaultConfig {
       testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
               }
            }
        
     dependencies {  
       androidTestCompile 'com.android.support:support-annotations:23.+'
       androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1'
       androidTestCompile 'com.android.support.test:runner:0.4.1'
       androidTestCompile 'com.android.support.test.espresso:espresso-intents:2.2.1'
        /**
         * AccessibilityChecks
         * CountingIdlingResource
         * DrawerActions
         * DrawerMatchers
         * PickerActions (Time and Date picker)
         * RecyclerViewActions
         */
        } 
    
    注意:这里最重要的是声明
    AndroidJUnitRunner
    为您的浓缩咖啡测试跑步者,因为我们将在我们的测试中使用
    JUnit4
    测试配置

    最后更改测试类代码,如下所示:

     @RunWith(AndroidJUnit4.class)
     @FixMethodOrder(MethodSorters.NAME_ASCENDING) 
     public class EspressoExampleTest {
    
     @Rule
     public ActivityTestRule<MainActivity> mRule = new ActivityTestRule<>(MainActivity.class);
    
     @Test
     public void checkIfAppNameIsDisplayed() {
         onView(withText(R.string.app_name)).check(matches(isDisplayed()));
     }
    

    它应该可以工作。

    我没有仔细考虑,但创建自己的ViewAction可能会停止测试,如下所示:

     @RunWith(AndroidJUnit4.class)
     @FixMethodOrder(MethodSorters.NAME_ASCENDING) 
     public class EspressoExampleTest {
    
     @Rule
     public ActivityTestRule<MainActivity> mRule = new ActivityTestRule<>(MainActivity.class);
    
     @Test
     public void checkIfAppNameIsDisplayed() {
         onView(withText(R.string.app_name)).check(matches(isDisplayed()));
     }
    

    onView(使用文本(R.string.some_text)).perform(等待(3*60))

    暂停UI测试以检查输出是最佳实践。这在道德上等同于在后端测试期间编写跟踪语句(
    Log.d()
    etc)。(应该有人写一本书!)我们如何创建一个“自定义空闲资源类”@IgorGanapolsky check或者Chiuki有一个很好的IdlingResource示例:您找到了这个问题的适当解决方案吗?我也在想同样的问题。