After adding this to my Android project, normal JUnit tests fail
See original GitHub issueUsing version 1.4.0.
I get this error:
java.lang.AbstractMethodError: org.powermock.api.mockito.internal.mockmaker.PowerMockMaker.isTypeMockable(Ljava/lang/Class;)Lorg/mockito/plugins/MockMaker$TypeMockability;
This test passed prior to adding mockito-kotlin. It complains on this line:
Thing thing = Mockito.mock(Thing.class); // Thing is a public INTERFACE defined in Java
If I remove that, the test still fails, but at a different line. I think it’s here:
@Mock Thing2 thing2; // Thing2 is a public non-final CLASS defined in Java
Other dependencies in build.gradle
:
testCompile 'junit:junit:4.12'
testCompile 'org.hamcrest:hamcrest-library:1.3'
testCompile 'org.mockito:mockito-core:2.0.5-beta'
testCompile("org.powermock:powermock-api-mockito:$powermock_version") { // 1.6.2
exclude module: 'hamcrest-core'
exclude module: 'objenesis'
}
testCompile("org.powermock:powermock-module-junit4:$powermock_version") {
exclude module: 'hamcrest-core'
exclude module: 'objenesis'
}
Issue Analytics
- State:
- Created 6 years ago
- Comments:7
Top Results From Across the Web
After adding this to my Android project, normal JUnit tests fail
Using version 1.4.0. I get this error: java.lang.AbstractMethodError: org.powermock.api.mockito.internal.mockmaker.PowerMockMaker.
Read more >Android Studio import existing unit tests "Unable to find ...
In EditConfigurations -> General tab -> Specific Instrumentation Runner (optional) This is existing in Android Studio 2.2 and version before only, in latest ......
Read more >Build local unit tests - Android Developers
Unit tests are usually simple but their setup can be problematic when the unit under test is not designed with testability in mind:....
Read more >AS 4.1+ fail to run junit tests, compailing about junit version ...
!!! JUnit version 3.8 or later expected: java.lang.RuntimeException: Stub! ... The issue is we're running JUnit 4.13, which is higher than 3.8. Things...
Read more >Frequently Asked Questions - JUnit 5
A test fixture is useful if you have two or more tests for a common set of objects. Using a test fixture avoids...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@starkej2 thanks for asking; I had meant to return and discuss my findings. Basically, I just removed PowerMock from the project. It has a strict dependency on a beta version of Mockito2, and it did not seem as if it would be updating that in the near future. Fortunately, after some refactorings it was no longer necessary for us to use PowerMock – normal Mockito was fine.
A caveat: if/when you update Mockito to the latest, and assuming you also use Hamcrest, you’ll find a few breaking changes from the Mockito beta. They’re relatively easy to fix, however.
I appear to be caught in dependency hell. Our project also uses PowerMock, which has a hardcoded dependency on an old version of Mockito. From my investigation so far, this won’t really be fixed until PowerMock 2 is released, and no clue when that will be.
I’ll hack away at it a bit more (with an axe), and update this issue if I find a solution. Thanks for the hint about Mockito 2.7.21.