java .lang.NoClassDefFoundError: Ошибка при разрешении: Landroidx / test / internal / runner / listener / InstrumentationRunListener - PullRequest
2 голосов
/ 09 июля 2020

При выполнении кода модульного теста возникла следующая ошибка.

java .lang.NoClassDefFoundError: Неудачное разрешение: Landroidx / test / internal / runner / listener / InstrumentationRunListener;

Мой код Unit Test выглядит следующим образом

@RunWith(AndroidJUnit4::class)
@LargeTest
class TestHomePageFragment {

 /*   @get:Rule
    var activityRule: ActivityTestRule<AudioPlayerActivity>
            = ActivityTestRule(AudioPlayerActivity::class.java)*/

    @Before
    fun setup(){

        val appContext: Context = InstrumentationRegistry.getInstrumentation().context
        val intent = Intent(appContext, AudioPlayerActivity::class.java)
        intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
        intent.putExtra(HomePageArouterConstants.KEY_ID,"1")
        val activityTestRule: ActivityTestRule<AudioPlayerActivity> = ActivityTestRule<AudioPlayerActivity>(AudioPlayerActivity::class.java, false, false)
        activityTestRule.launchActivity(intent)
    }



    @Test
    fun testVote(){
        onView(withId(R.id.linear_layout_like)).perform(click())
    }

}

Файл Build.gradle

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


    dependencies {
    
    //    androidTestImplementation "androidx.test:core:$rootProject.testCoreVersion"
        androidTestImplementation rootProject.ext.dependencies["test-core"]
    //    androidTestImplementation "androidx.test:runner:$rootProject.testRunnerVersion"
        androidTestImplementation rootProject.ext.dependencies["test-runner"]
    //    androidTestImplementation "androidx.test:rules:$rootProject.testRulesVersion"
        androidTestImplementation rootProject.ext.dependencies["test-rules"]
    
    //    androidTestImplementation "androidx.appcompat:appcompat:$rootProject.appCompatVersion"
        androidTestImplementation rootProject.ext.dependencies["androidx-appcompat"]
    //    androidTestImplementation "androidx.recyclerview:recyclerview:$rootProject.recyclerViewVersion"
        androidTestImplementation rootProject.ext.dependencies["recyclerview"]
    //    androidTestImplementation "com.google.android.material:material:$rootProject.materialVersion"
        androidTestImplementation rootProject.ext.dependencies["material"]
    
    //    androidTestImplementation "androidx.test.espresso:espresso-core:$rootProject.espressoVersion"
        androidTestImplementation rootProject.ext.dependencies["espresso-core"]
    //    androidTestImplementation "androidx.test.espresso:espresso-contrib:$rootProject.espressoVersion"
        androidTestImplementation rootProject.ext.dependencies["espresso-contrib"]
    //    androidTestImplementation "androidx.test.espresso:espresso-intents:$rootProject.espressoVersion"
        androidTestImplementation rootProject.ext.dependencies["espresso-intents"]
    //    androidTestImplementation "androidx.test.ext:junit:$rootProject.testExtJunit"
        androidTestImplementation rootProject.ext.dependencies["test-junit"]
    //    androidTestImplementation "androidx.test.uiautomator:uiautomator:$rootProject.uiAutomatorVersion"
        androidTestImplementation rootProject.ext.dependencies["test-uiautomator"]
    //    androidTestImplementation "androidx.work:work-testing:$rootProject.workVersion"
        androidTestImplementation rootProject.ext.dependencies["work-testing"]
    
    //    androidTestImplementation "androidx.arch.core:core-testing:$rootProject.coreTestingVersion"
        androidTestImplementation   rootProject.ext.dependencies["core-testing"]
    //    androidTestImplementation "org.mockito:mockito-core:$rootProject.mockitoVersion"
        androidTestImplementation rootProject.ext.dependencies["mockito-core"]
    //    androidTestImplementation "org.mockito:mockito-android:$rootProject.mockitoAndroidVersion"
        androidTestImplementation rootProject.ext.dependencies["mockito-android"]
    
    }

У меня есть Google для этого, но ни один из ответов не может разобраться . Есть идеи для решения этой проблемы?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...