Eup*_*r08 20 android automated-tests android-studio
我尝试为我的 Android 应用程序(Java)实现一些单元和仪器测试,我的单元测试工作正常,但仪器测试失败:
@RunWith(AndroidJUnit4.class)
@LargeTest
public class ExampleInstrumentedTest {
@Rule
public IntentsTestRule<MainActivity> mActivityRule = new IntentsTestRule<>(MainActivity.class);
@Test
public void checkIfCategoriesIsNotEmpty() {
onView(withId(R.id.header_left_layout)).perform(click());
onView(withId(R.id.list_view)).check(new ViewAssertion() {
@Override
public void check(View view, NoMatchingViewException noViewFoundException) {
ListView list_categories = (ListView) view;
ListAdapter adapter = list_categories.getAdapter();
Assert.assertTrue(adapter.getCount() > 0);
}
});
}
}
Run Code Online (Sandbox Code Playgroud)
当我尝试运行测试时出现此错误:
"Run Android instrumented tests using Gradle" option was ignored because this module type is not supported yet.
Run Code Online (Sandbox Code Playgroud)
我在 build.config 文件中的实现是:
// UNIT TEST
testImplementation 'junit:junit:4.12'
testImplementation 'org.hamcrest:java-hamcrest:2.0.0.0'
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.7.1'
// INSTRUMENTED TEST
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.4.0'
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.4.0'
Run Code Online (Sandbox Code Playgroud)
小智 28
我刚刚也遇到了这个问题。我在Android Studio Bumblebee 2021.1.1 发行说明的“Android 测试”部分找到了解决方案。
它基本上相当于取消选中测试设置中使用 Gradle 运行 Android 仪器测试旁边的框。这对我有用。
解决方案是排除模块:protobuf-lite:
androidTestImplementation('androidx.test.espresso:espresso-contrib:3.4.0') {
exclude module: "protobuf-lite"
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14957 次 |
| 最近记录: |