From jetbrains blog:
IntelliJ IDEA supports the ability to actually run tests written for JUnit 5 – there’s no need to use the additional libraries (like the Gradle or Maven plugins for example), all you need is to include the JUnit 5 dependency.
I'm new to Java and IntelliJ IDEA and it's not clear to me what are the steps that I should do for making test using Junit 5.
If your project is Maven or Gradle based, the dependency is added via pom.xml or build.gradle, otherwise you just add the .jar files to the Module Dependencies.
IDE can help you with that, press Alt+Enter on the red code:
The following dependencies will be downloaded from the Maven repository and added to the classpath:
I made this work by adding this to my pom:
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.0.0-M4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>1.0.0-M4</version>
<scope>test</scope>
</dependency>
Previously you need plugin to run unit test like this
buildscript {
repositories {
mavenCentral()
// The following is only necessary if you want to use SNAPSHOT releases.
// maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
}
dependencies {
classpath 'org.junit.platform:junit-platform-gradle-plugin:1.0.0-M2'
}
}
apply plugin: 'org.junit.platform.gradle.plugin'
But for JUnit5 no need of plugin just compile
dependencies {
testCompile 'org.junit.jupiter:junit-jupiter-api:5.0.0-M2'
}