question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

After adding this to my Android project, normal JUnit tests fail

See original GitHub issue

Using 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:closed
  • Created 6 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
autonomousappscommented, Jun 9, 2017

@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.

1reaction
autonomousappscommented, Apr 30, 2017

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found