Rui
Rui

Reputation: 3667

Why is maven-surefire-plugin compulsory when using JUnit 5 in a Maven project?

I have used JUnit 3 and 4 for a long time in maven projects without maven-surefire-plugin.

Currently I started to try JUnit 5 by using the annotation from the JUnit Jupiter package org.junit.jupiter.api. Especially org.junit.jupiter.api.Test is used instead of the legacy org.junit.Test. Eventually, No tests were detected and thus the testing failed.

The maven-surefire-plugin has to be added to pom.xml as such: ```

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

<build>
  <plugins>
    <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.19.1</version>
        <dependencies>
                <dependency>
                    <groupId>org.junit.platform</groupId>
                    <artifactId>junit-platform-surefire-provider</artifactId>
                    <version>${junit.platform.version}</version>
                </dependency>
        </dependencies>
    </plugin>
  </plugins>
</build>

So Hereby I would like to ask:

It is my habit to make the code as simple as possible

Upvotes: 1

Views: 548

Answers (1)

khmarbaise
khmarbaise

Reputation: 97467

Junit5 support in maven-surefire-plugin is not yet finished and needs a new release of maven-surefire-plugin which is currently being worked on

Upvotes: 1

Related Questions