简体   繁体   中英

Unable to run Android Instrumented Tests

I am trying to run some UI tests using espresso on AS Arctic Fox 2020.3.1 Patch 3 ARM preview. Following Google instructions for setting up these are my dependencies:

// Core library
androidTestImplementation 'androidx.test:core:1.4.0'

// AndroidJUnitRunner and JUnit Rules
androidTestImplementation 'androidx.test:runner:1.4.0'
androidTestImplementation 'androidx.test:rules:1.4.0'
androidTestUtil 'androidx.test:orchestrator:1.4.0'

// Assertions
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.ext:truth:1.4.0'
androidTestImplementation 'com.google.truth:truth:1.0.1'

// Espresso dependencies
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'
androidTestImplementation 'androidx.test.espresso:espresso-accessibility:3.4.0'
androidTestImplementation 'androidx.test.espresso:espresso-web:3.4.0'
androidTestImplementation 'androidx.test.espresso.idling:idling-concurrent:3.4.0'

I have also added the testInstrumentationRunner in my Gradle to testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

I am trying to run the simplest possible test below:

import androidx.test.ext.junit.runners.AndroidJUnit4
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
class DummyTest {

   @Test
   fun test() {
       assert(false)
   }
}

but when I click the Run of my test it looks like I have 0 tests. Is there something I am missing? Thanks

If AS shows TestResult 0/0, delete that dependency

androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.4.0'

Found a way to fix this one after spending many hours. I noticed that the issue had to do with the

androidx.test.espresso:espresso-contrib:3.4.0

check this answer for more insight link

Thought I was not getting any errors or issues. I had to disable the Test Matrix of the AS. After disabling I was getting more clear framework crash errors in the logical which helped me identify the issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM