junit5执行maven test

274 阅读1分钟

junit 5执行maven test

不知道什么问题,junit5执行maven test的时候测试用例不执行,调了很久,还删了一把库,最后查看了官网的配置,才终于成功了 pom.xml配置中需要加上sufire插件,添加下面代码到pom.xml中:

<dependencies>
    [...]
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-api</artifactId>
        <version>5.4.0</version>
        <scope>test</scope>
    </dependency>
    [...]
</dependencies>
...
<build>
    <plugins>
        [...]
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>3.0.0-M5</version>
            [... configuration or goals and executions ...]
        </plugin>
        [...]
    </plugins>
</build>

结果如下: image.png 参考:maven.apache.org/surefire/ma…