gpt4 book ai didi

android - Espresso Instrumentation Tests - 如何在测试后卸载或删除应用程序

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:30:39 27 4
gpt4 key购买 nike

我设置了 Espresso 检测框架来运行我的 Android 功能自动化测试。对于每次测试,我都想在完成测试后登录到该应用程序并删除该应用程序。

所以,我设置如下:

公共(public)类 FirstSampleTest 扩展 BaseTest {

private final BaseTest baseTest;

//private final 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
}

}

最佳答案

您可以在 Run -> Edit Configurations 的 Android Studio Before launch 部分添加 gradle 任务

点击 + -> 添加一个 gradle-aware Make -> :app:uninstallAll

注意::app:uninstallAll 中的“app”取决于您的ma​​in 模块名称。所以它可以是:my_module:uninstallAll,或者:company:uninstallAll

关于android - Espresso Instrumentation Tests - 如何在测试后卸载或删除应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35275345/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com