Getting a JUnit version error after adding new dependencies.


So i added two new dependencies to use PowerMock in addition to other previous dependencies. Now I'm getting an error:

FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:test'.
> Test filtering is not supported for given version of JUnit. Please upgrade JUnit version to at least 4.6.

And here are my Gradle dependencies:

dependencies {
  testCompile 'org.codehaus.groovy:groovy-all:2.3.7'
testCompile "junit:junit:$junitVersion"
testCompile ""
testCompile 'org.powermock:powermock-api-mockito:1.6.1'
testCompile 'org.powermock:powermock-module-junit4:1.6.1'
testCompile 'org.mockito:mockito-core:1.9.5'

I added the 2 PowerMock dependencies. And $junitVersion is 4.11.

Before the dependencies the tests were fine. I can run gradle tests on command line aswell and everything works fine.

Comment actions Permalink

Please provide a project to reproduce this issue.

Comment actions Permalink

The problem was that PowerMock version 1.6.1 needed Junit 4.12, but the version I used was 4.11.
I downgraded PowerMock to 1.6.0, which uses Junit 4.11 and it works now.

When I had the problem, then IDEA did install 4.12, but when lookng at the gradle dependency tree, I could see that


had JUnit 4.12 as a needed dependency, which was grayed out.
I'm guessing that IDEA did not find the 4.12 version and was using some other version wich wasn't 4.11 or it just didn't find any version at all and the error report was misguiding.


Please sign in to leave a comment.