我开始使用Espresso Framework和UI Automator在android中编写UI测试。
因此,我编写了3个不同的UI测试,每个测试都包含身份验证过程。当我单独运行每个测试时,它们都工作得很好。但是,当我使用./gradlew connectedAndroidTest运行所有3个测试时,第一个测试通过,其他两个测试失败,因为它会自动登录(我使用webview登录,所以它会将我重定向到主屏幕)。我尝试过this solution,但它不起作用。
我想要归档的是,在每次测试之后,使用InstrumentationRegistry.getInstrumentation().getUiAutomation().executeShellCommand("pm clean com.example.app")清除数据,并为每次测试重新开始。
当我在@After中执行此命令时,测试崩溃:
Test failed to run to completion. Reason: 'Instrumentation run failed due to 'Process crashed.''.你知道我怎么才能把这个存档吗?
发布于 2020-07-30 07:07:30
我建议您使用Android Test Orchestrator,因为它将在单独的进程中运行每个测试,这意味着不会与其他测试共享任何状态或数据。
https://stackoverflow.com/questions/63137468
复制相似问题