powermock / powermock

PowerMock is a Java framework that allows you to unit test code normally regarded as untestable.
Apache License 2.0
4.16k stars 584 forks source link

cannot access Stubber class file for org.mockito.stubbing.Stubber not found #820

Open mikelupo opened 7 years ago

mikelupo commented 7 years ago

At build time, I'm getting a compiler complaint as seen in subject line. PowerMockito.doReturn(someObjectToReturn).when(someCondition) //complains about the return type on the doReturn.

I think this is build.gradle hell.

Below is how I'm including PowerMock on an android project. Using compile (not androidTestCompile) intentionally as the app is a shell that integrates a library (the library is what we write and are testing). We have some mocks set up in the main app to override getSystemService so we can influence ConnectivityManager.

    compile ('org.powermock:powermock-api-mockito2:1.7.0') {
        exclude group: 'org.mockito', module: 'hamcrest-core'
        exclude group: 'org.hamcrest', module: 'hamcrest-core'
        exclude group: 'junit' exclude group: 'org.mockito'
        exclude group: 'org.objenesis', module: 'objenesis'
    }

I thought, "Geesh this is easy". Get rid of "exclude group: 'junit' exclude group: 'org.mockito'" and that class will be found. But when I remove that exclude line, I have another error,

Error:Execution failed for task ':mapclient:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/powermock/api/mockito/expectation/WithExpectedArguments.class

Open for some suggestions here.

NickL77 commented 5 years ago

Was this ever solved? I'm running into the same issue.

mikelupo commented 5 years ago

I’ve abandoned its use. We use mockwebserver instead