【发布时间】:2021-06-29 12:21:22
【问题描述】:
我在构建我的 java 项目时使用 maven,并且我正在使用 JUnit5 框架进行测试,当我尝试运行测试代码时,我收到了以下消息:
Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.10:test (default-cli) on project transaction-processor: No tests were executed! (Set -DfailIfNoTests=false to ignore this error.) -> [Help 1]
这是 POM.xml:
<?xml version="1.0" encoding="UTF-8"?>
<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>
<groupId>com.progressoft.induction</groupId>
<artifactId>transaction-processor</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<testFailureIgnore>false</testFailureIgnore>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.6.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
</dependency>
</dependencies>
</project>
我该如何解决这个问题,问题是什么?
【问题讨论】:
-
看起来surefire希望你至少有一个测试用例。以正确定义的结构编写单元测试用例或设置 -DfailIfNoTests=false
-
你要运行的 mvn 命令是什么?
标签: java maven testing junit junit5