Setup and install JUnit 5 using Maven

JUnit 5 and Maven

Setting up JUnit 5 in a Maven project is very simple.

JUnit pom.xml

In your maven project, navigate to your pom.xml file and add the following lines:

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>${maven.compiler.source}</maven.compiler.target>
        <junit.jupiter.version>5.6.2</junit.jupiter.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <version>${junit.jupiter.version}</version>
        </dependency>
    </dependencies>

Trigger Maven or your IDE to import the dependencies that you added.

Once that is completed, JUnit is ready for you to start writing tests.

Happy testing!

References

https://github.com/junit-team/junit5-samples/tree/r5.6.2/junit5-jupiter-starter-maven

https://junit.org/junit5/

https://junit.org/junit5/docs/current/user-guide/#overview

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *