简体   繁体   English

Espresso Instrumentation测试-测试后如何卸载或删除应用

[英]Espresso Instrumentation Tests - how to uninstall or delete the app after the test

I setup Espresso instrumentation framework to run my Android Functional Automation tests. 我设置了Espresso工具框架来运行我的Android Functional Automation测试。 For every test, I want to login to the app and delete the app after I finish the test. 对于每个测试,我都想登录到该应用程序并在完成测试后删除该应用程序。

So, I setup something like below: 因此,我设置如下所示:

public class FirstSampleTest extends BaseTest { 公共类FirstSampleTest扩展了BaseTest {

private final BaseTest baseTest;

// private final ElementUtils elementUtils; //私有最终ElementUtils elementUtils;

public FirstSampleTest() throws InterruptedException {
    this.baseTest = new BaseTest();
}

@Before
public void initiate() throws InterruptedException {
    //I have setup login method here to login to the app after it installs
}

@Rule
public ActivityTestRule<SplashScreenActivity> splashScreenActivityActivityTestRule = new ActivityTestRule(SplashScreenActivity.class);

@Test
public void testTheHomeScreen() throws InterruptedException {
   //Some tests go here. 
}

@After
public void teardown() throws InterruptedException {
    //I want to uninstall the app or delete it from the emulator once the test is run 
}

}

Uninstalling the app from the Instrumentation tests is not possible. 无法从Instrumentation测试中卸载该应用。 However, once all the tests are run, the app is uninstalled automatically. 但是,一旦运行了所有测试,该应用程序将自动卸载。

Note: The app is not uninstalled only when a single test is run. 注意:仅当运行单个测试时,才会卸载应用程序。 Please run the whole build using the command ./gradlew connectedAndroidTest 请使用命令./gradlew connectedAndroidTest运行整个构建

You can add a gradle task in the Android Studio Before launch section in Run -> Edit Configurations . 您可以在Run -> Edit Configurations中的Android Studio Before launch部分中添加gradle任务

Click + -> Add a gradle-aware Make -> :app:uninstallAll 单击+ ->添加可识别gradle的Make-> :app:uninstallAll

note: "app" in :app:uninstallAll depends on your main module name. 注意:: :app:uninstallAll “ app”取决于您的模块名称。 So it can be :my_module:uninstallAll , or :company:uninstallAll 因此可以是:my_module:uninstallAll:company:uninstallAll

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Firebase测试实验室中并行运行Espresso工具测试? - How to run Espresso instrumentation tests in parallel in Firebase Test Lab? 如何在 android Espresso 仪器测试中从最近的应用程序中获取 select 应用程序 - How to select app fro recent apps in android Espresso Instrumentation Test Android 仪器测试:“找不到测试类”使用 Espresso 和 Spoon - Android Instrumentation Tests: 'Could not find test class' using Espresso and Spoon 运行意式浓缩咖啡测试时,测试仪器过程崩溃 - Test instrumentation process crashed while running espresso tests 将应用程序转换为即时应用程序后如何运行仪器测试? - How to run instrumentation tests after converting app to instant app? 在“由于程序崩溃”导致仪器运行失败后,如何恢复Android Espresso测试? - How to resume Android Espresso test after 'Instrumentation run failed due to 'Process crashed.''? Android:Espresso测试套件-如何在模拟器上已存在的应用程序上运行espresso测试 - Android : Espresso Test kit - How to run espresso tests on already existing app on emulator Androidx:如何在 UI 测试(Espresso)中测试 Slider? - Androidx : How to test Slider in UI tests (Espresso)? Espresso 2升级后测试失败(失败:由于&#39;java.lang.IllegalAccessError&#39;导致仪器运行失败) - Tests fail after Espresso 2 upgrade (failed: Instrumentation run failed due to 'java.lang.IllegalAccessError') 了解 Android Espresso 仪器测试的结果 - Understanding results of Android Espresso instrumentation test
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM