gpt4 book ai didi

AndroidX Espresso 测试 : No tests were found and Empty test suite

转载 作者:行者123 更新时间:2023-11-29 00:56:47 25 4
gpt4 key购买 nike

我正在尝试运行 src/androidTest,这是我使用 AndroidX 库的 Android 项目中的仪器测试,但我得到的是 No tests were found 错误和空测试套件 日志。

我已经检查了所有使用 AndroidX 库的示例和文档都在做同样的事情。

我已尝试根据以下链接设置 Edit Configurations https://stackoverflow.com/a/53715513/1826656但仍然没有运气。

我做错了什么吗?或缺少任何步骤?

请检查此图片是否为 Test Run log

MainActivityTest.java 代码:

import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.action.ViewActions.typeText;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static androidx.test.espresso.matcher.ViewMatchers.withText;

@RunWith(AndroidJUnit4.class)
@LargeTest
public class MainActivityTest {

@Rule
ActivityTestRule mActivityRule = new ActivityTestRule<>(MainActivity.class, false, false);

@Test
public void checkViewsVisibility() {
// verify the visibility of recycler view on screen
onView(withId(R.id.record_list_rv)).check(matches(isDisplayed()));

// verify the visibility of progressbar on screen
onView(withId(R.id.progressBar)).check(matches(isDisplayed()));

// verify the visibility of no data TextView on screen By default it should be GONE
onView(withId(R.id.no_data_tv)).check(matches(isDisplayed()));

onView(withId(R.id.no_data_tv)).check(matches(withText("No Data")));

onView(withId(R.id.no_data_tv)).perform(typeText("No Data"));
}
}

Gradle 文件依赖:

android {
defaultConfig {
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunne"
}

testOptions {
execution 'ANDROIDX_TEST_ORCHESTRATOR'
}
}

dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestUtil 'androidx.test:orchestrator:1.1.1'
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test:rules:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.1.1'
}

最佳答案

您的 defaultConfig 中有错字。应该是:

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

关于AndroidX Espresso 测试 : No tests were found and Empty test suite,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54161491/

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