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

63 views Asked by At

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 ?

2

There are 2 answers

0
C.B. On BEST ANSWER

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

0
Aamir Naved On

Check for any dependency conflicts in your project. It's possible that there are conflicting versions of libraries that are causing issues. Look for multiple versions of hamcrest-core or any other dependencies that might be related to Matchers. If you find conflicting versions, you can try excluding one version to resolve the conflict.

implementation("com.google.testparameterinjector:test-parameter-injector:1.14") { exclude group: 'org.hamcrest', module: 'hamcrest-core' }