mardi 2 avril 2019

Android: How can I use Mock on both test code?

I am developing an android app using "Android Jetpack WorkManager".

My presenter code uses it.

I want to test my presenter code.

First I tried to use the JUnit test, but because of WorkManager, I am changing it to AndroidTest. Below is my build.gradle.

dependencies {
    testImplementation 'junit:junit:4.12'
    testImplementation 'org.mockito:mockito-all:1.10.19'
}

In this case, I cannot use "Mock" in my AndroidTest code. So I changed the dependency like:

dependencies {
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'org.mockito:mockito-all:1.10.19'
}

Then, I cannot use "Mock" in my JUnit test code. So I tried:

dependencies {
    testImplementation 'junit:junit:4.12'
    testImplementation 'org.mockito:mockito-all:1.10.19'
    androidTestImplementation 'org.mockito:mockito-all:1.10.19'
}

This doesn't work too...

How should I do that?

Aucun commentaire:

Enregistrer un commentaire