【发布时间】:2019-01-28 08:10:55
【问题描述】:
给定一个文件夹结构:
theProject/src/com/myclass/tests/api/APITest
包声明在哪里:
package com.myclass.tests.api;
它使用来自 testng 的 @Test。
在 pom.xml 中,我已经包含了构建部分:
<build>
<testSourceDirectory>${project.basedir}/</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<includes>
<include>**/*Test.class</include>
<include>**/*test.class</include>
<include>src/com/myclass/tests/api/*Test.class</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
我尝试在 theProject 文件夹(pom.xml 所在的文件夹)中执行以下命令。
mvn test -Dtest=com.myclass.tests.api.*
但结果给出:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test (default-test) on project theProject: No tests were executed! (Set -DfailIfNoTests=false to ignore this error.) -> [Help 1]
我应该如何从 mvn 运行测试?
【问题讨论】:
-
你能分享你的 pom.xml 吗?