JUnit 5 Tutorials

junit 5 logo

JUnit 5 = JUnit Platform + JUnit Jupiter + JUnit Vintage

P.S JUnit 5 requires Java 8 (or higher) at runtime

1. JUnit 5 + Maven

See this full JUnit 5 + Maven examples.

pom.xml

<dependency>
	<groupId>org.junit.jupiter</groupId>
	<artifactId>junit-jupiter-engine</artifactId>
	<version>5.5.2</version>
	<scope>test</scope>
</dependency>

<build>
    <plugins>
		<plugin>
			<groupId>org.apache.maven.plugins</groupId>
			<artifactId>maven-surefire-plugin</artifactId>
			<version>3.0.0-M3</version>
		</plugin>
	</plugins>
</build>

P.S The maven-surefire-plugin must be at least version 2.22.0

2. JUnit 5 + Gradle

See this full JUnit 5 + Gradle examples.

gradle.build

plugins {
	id 'java'
	id 'eclipse' // optional, for Eclipse project
	id 'idea'	 // optional, for IntelliJ IDEA project
}

repositories {
	mavenCentral()
}

dependencies {
	testImplementation('org.junit.jupiter:junit-jupiter:5.5.2')
}

test {
	useJUnitPlatform()
}

3. JUnit 5 Tests

4. Third-party Assertion Libraries

5. Integration

Download Source Code

References

mkyong

Founder of Mkyong.com, passionate Java and open-source technologies. If you enjoy my tutorials, consider making a donation to these charities.

2 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
Goden
5 years ago

Great! Very helpful to me…
Continue reading…

Last edited 5 years ago by Goden
Mamta Sharma
6 years ago

nice