android-espressohamcrestandroid-junit

Can't use Espresso test parameter injector with org hamcrest Matchers?


Within an existing project with espresso tests, I want to parameterized espresso tests so I add in the project configuration the declaration

implementation 'com.google.testparameterinjector:test-parameter-injector:1.14'

Then after synchronization, in the AndroidJUnit4 kotlin test classes, I got an error message for importing Matchers and I cannot execute the tests anymore and I still haven't parameterized the tests

import org.hamcrest.Matchers.*

Unresolved reference:Matchers

What's wrong with both libraries or my usage ?


Solution

  • My workaround to the problem of this probable dependency conflict is to import the library only for the tests and that's not a restriction since it's only for testing !

    androidTestImplementation 'com.google.testparameterinjector:test-parameter-injector:1.14'

    and then it compiles