Main Tutorials

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

About Author

author image
Founder of Mkyong.com, love Java and open source stuff. Follow him on Twitter. If you like my tutorials, consider make a donation to these charities.

Comments

Subscribe
Notify of
2 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
Goden
3 years ago

Great! Very helpful to me…
Continue reading…

Last edited 3 years ago by Goden
Mamta Sharma
3 years ago

nice