Intellij Idea with Junit 4.7 "!!! Junit Version 3.8 or Later Expected:"

IntelliJ IDEA with Junit 4.7 !!! JUnit version 3.8 or later expected:

This problem happens because Android Platform (android.jar) already contains JUnit classes. IDEA test runner loads these classes and sees that they are from the old JUnit, while you are trying to use annotated tests which is a feature of the new JUnit, therefore you get the error from the test runner.

The solution is simple, open the Project Structure | Modules | Dependencies, and move the junit-4.7.jar up, so that it comes before Android 1.6 Platform in the classpath. Now the test runner will be happy as it loads the new JUnit version.

JUnit version 3.8 or later expected on android studio 4.1

I had the same issue when I upgrade to AS 4.1

I resolved this by removing the following from the build.gradle (app) file

useLibrary 'android.test.runner'

All tests run to completion

Error JUnit version 3.8 or later expected - Android Studio

Hm, why didn't you try

testCompile 'junit:junit:3.8'

?

Android Studio 3.0 JUnit version 3.8 or later expected

This is not the solution, just a messy workaround (since it took too much time to solve it):

Uninstall and install the android studio 3.0 again. Do not update the
kotlin plugin and the android studio to newer versions.

IntelliJ Idea not resolving Mockito and JUnit dependencies with Maven

Try View -> Tool Windows -> Maven projects, then click the blue icon in the top left of the tool window (Reimport all Maven projects). You should be able to find the dependencies in the project view, under external libraries.

If this does not work, there is probably something wrong with your maven config (pom.xml). Try mvn clean install from the command line see if it gives any errors.

Android Studio - with Junit 4.12 “!!! JUnit version 3.8 or later expected:”

Solved the issue. I was running the JUnit tests as a standard "JUnit test" in Android Studio. I fixed the issue by resetting the configuration as a Android Test.

Junit5 with IntelliJ and Gradle

Adding specific dependencies solve the problem.

NOTE: UPDATE INTELLIJ ABOVE 2017.2.0 AS THERE WAS A BUG WITH THE JUNIT LAUNCHER

OXYGEN if you using eclipse.


Below dependency enables Junit5 parametrized tests which can be used instead of a DataProvider.

"org.junit.jupiter:junit-jupiter-params:5.0.0"
//for JUnit5 parametrized tests.

Junit5 API.

"org.junit.jupiter:junit-jupiter-api:5.0.0"
//JUnit5 API

Needed if you want to run legacy JUnit4 tests without changing the syntax and imports.

"org.junit.vintage:junit-vintage-engine:4:12.0"
//for legacy JUnit4 tests

EDIT: 07/2018 Match the version of the vintage runner to the jupiter version


Needed if you want to run JUnit5 tests with new syntax and imports.

"org.junit.jupiter:junit-jupiter-engine:5.0.0"
//for JUnit5 tests

java.lang.NoSuchMethodError: org.junit.platform.engine.EngineDiscoveryRequest.getDiscoveryFiltersByType(Ljava/lang/Class;)Ljava/util/List;


Launcher.

"org.junit.platform:junit-platform-launcher:1.0.0
//to handle default launcher

Exception in thread "main" java.lang.NoSuchMethodError: org.junit.platform.commons.util.ReflectionUtils.getDefaultClassLoader()Ljava/lang/ClassLoader;


Additional info how to install JUnit5


Since version 4.6 for Gradle, there is no need for plugins anymore
Gradle supports Junit5 natively just do:

And the version of the vintage runner is now same as the JUnit 5 version.

dependencies {

testImplementation "org.junit.jupiter:junit-jupiter-params:$junitVersion"
testImplementation "org.junit.jupiter:junit-jupiter-api:$junitVersion"

testRuntimeOnly "org.junit.vintage:junit-vintage-engine:$junitVersion"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junitVersion"
}

test {
useJUnitPlatform {
includeEngines 'junit-jupiter', 'junit-vintage'
}
}


Related Topics



Leave a reply



Submit