Maven 找不到测试



我有一个Maven项目设置。在项目中,我使用 JUnit 进行单元测试。当我使用mvn testmvn clean test运行测试时,不会运行任何测试。测试src/test/java,它们都以Test结尾(它们与*Test.java匹配(。

这是我的绒球.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.9</source>
<target>1.9</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.0.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>5.1.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.1</version>
</dependency>
</dependencies>
<groupId>org.astropeci.ppp4e</groupId>
<artifactId>ppp4e</artifactId>
<version>1.0</version>
</project>

我的整个项目结构可以在这里看到:https://bitbucket.org/equator-lang/ppp4e/src/master/

任何帮助将不胜感激,因为我已经尝试了很多小时才能让它工作并且不知道该怎么做。

编辑:

公开测试类后,Maven 响应从

-------------------------------------------------------
T E S T S
-------------------------------------------------------
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

自:

-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running org.astropeci.ppp4e.defaultimpl.internal.lexing.MultiplexedTokenBuilderTest
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.002 sec
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

>JUnit 5 支持尚未内置到负责运行单元测试的 maven-surefire-plugin 中。您需要使用提供程序配置插件才能使其工作。

我使用以下配置:

<properties>
...
<maven-surefire-plugin.version>2.20.1</maven-surefire-plugin.version>
<junit-5.version>5.2.0</junit-5.version>
</properties>
...
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<!-- JUnit 5 Support -->
<dependencies>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit-5.version}</version>
</dependency>
</dependencies>
</plugin>
...
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit-5.version}</version>
<scope>test</scope>
</dependency>
...

最新更新