浓缩咖啡和手动同时测试

问题描述:

我正在为通过NFC标签与仪器交互的Android应用程序编写Espresso自动化测试。在NFC读取和与仪器手动互动过程中,我想停止espresso测试3-4分钟。在espresso测试期间,我们可以同时进行自动化和人工交互。闲置资源是一种选择,因为在停机期间UI将发生变化。浓缩咖啡和手动同时测试

+0

我已经编辑过我的文章 – piotrek1543

那么,我不知道在同一时间进行自动化和手动测试,理论上自动化测试应该加速检查用户与应用程序的交互过程,并使一些工作中的手动测试人员变得容易。

在运行自动Espresso测试过程中进行手动测试真的是一个坏主意。中断测试或更改应用程序状态非常简单,这会导致测试失败。

最后一次谷歌测试自动化会议2015年宣布Barista - 记录仪用于Espresso测试。

在咖啡,我看到三种可能的方式做测试你的方式:

  1. 使定制空转资源类和注册。
  2. 使用Java空闲方法如Thread.sleep(240000);
  3. 编写您想要的所有自动化测试,运行它们。最后做 选择手动测试。

编辑:根据你的问题最好的想法是使用Thead.sleep(milliseconds)。它会停止测试所需的时间,如3或4分钟。

但咖啡测试以随机顺序,请重新配置这样您现有的配置运行:

build.gradle申报android -> defaultConfigtestInstrumentationRunner,当然咖啡,让您的摇篮文件应包含:

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作为您的Espresso测试跑步者,因为我们要使用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())); 
} 

这里@FixMethodOrder(MethodSorters.NAME_ASCENDING)使用会给您的测试类将逐步执行,此起彼伏,让我们以后的说你会放第8个测试班

@Test 
public void waitUntilManualTestWoulBeDone() { 
    Thread.sleep(1440000); //sleeps 4 minutes 
} 

它应该工作。

我没想到彻底,但创建自己的ViewAction这一可能停止测试,这样的事情:

onView(withText(R.string.some_text))执行(等待(3 * 60));