如何在Android Studio中使用特定注释运行Espresso测试?

问题描述 投票:0回答:1

例如,我想使用注释 @FlakyTest 运行所有测试。

@Test
@FlakyTest
fun sampleTest() {
    onView(...)
}

我的代码中还有许多其他使用@FlakyTest 的测试。

我可以从命令行执行此操作,如https://developer.android.com/reference/androidx/test/runner/AndroidJUnitRunner所说。

将测试运行过滤为具有给定注释的测试:

adb shell am instrument -w -e annotation com.android.foo.MyAnnotation com.android.foo/androidx.test.runner.AndroidJUnitRunner

我知道如何通过单击旁边的绿色播放按钮或创建一个测试字段为“方法”的运行/调试配置来在 Android Studio 中运行一个测试。但没有选择运行特定注释。

android android-studio android-espresso
1个回答
0
投票

您可以按照 Android 团队的描述编辑运行配置,将特定注释作为参数添加到检测参数中此处

Example screenshot

© www.soinside.com 2019 - 2024. All rights reserved.