Java Maven Surefire未执行测试阶段
运行Java Maven Surefire未执行测试阶段,java,maven,unit-testing,groovy,maven-surefire-plugin,Java,Maven,Unit Testing,Groovy,Maven Surefire Plugin,运行mvn测试时似乎surefire没有执行其测试目标(或者至少没有选择我在配置中包含的测试) 这是一个多模块maven项目,目前全部在groovy中,其结构类似于以下内容: root -commons -framework -generatedsources1 -generatedsources2 -test-groups --test-group1 ---src/test/java/path.to.TestClass.groovy --test-group2 我在测试组pom.xml中有以
mvn测试时
似乎surefire没有执行其测试目标(或者至少没有选择我在配置中包含的测试)
这是一个多模块maven项目,目前全部在groovy中,其结构类似于以下内容:
root
-commons
-framework
-generatedsources1
-generatedsources2
-test-groups
--test-group1
---src/test/java/path.to.TestClass.groovy
--test-group2
我在测试组
pom.xml中有以下surefire配置:
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<useFile>false</useFile>
<includes>
<include>**/*Spec.groovy</include>
<include>**/*Test.groovy</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
当我直接调用插件时:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building system-test-category-man 1.0.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-surefire-plugin:2.18.1:test (default-cli) @ system-test-category-man ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.315 s
[INFO] Finished at: 2018-01-08T10:58:18Z
[INFO] Final Memory: 9M/155M
[INFO] ------------------------------------------------------------------------
我是否配置错误?您是否尝试更改工作目录:
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<workingDirectory>wherever you have your tests</workingDirectory>
<useFile>false</useFile>
<includes>
<include>**/*Spec.groovy</include>
<include>**/*Test.groovy</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
maven surefire插件
2.18.1
无论你在哪里做测试
假的
**/*规范groovy
**/*Test.groovy
于2018年11月1日更新:
不确定这是否可以解决问题,但您是否可以尝试将这些依赖项添加为报告依赖项(在构建依赖项之外):
org.apache.maven.plugins
maven surefire报告插件
2.18.1
真的
假的
org.apache.maven.plugins
maven surefire插件
2.18.1
这个问题也让我困惑,但我想我发现了问题所在
从maven surefire插件的角度来看
Groovy类只不过是无意义的文本文件,它无法扫描注释。但是,我可以成功地指定
类名(本例将介绍所有内容):
org.apache.maven.plugins
事情是这样的:
**/Test*.java
**/*Test.java
**/*Tests.java
**/*TestCase.java
(此处将.java替换为.groovy)Garcia,是的,我有,它会产生相同的结果。也可以尝试使用/***Spec.groovy。不幸的是,注意开始/同样的事情-真正令人恼火的是,调试中似乎没有引用surefire:test。我已经更新了我的答案。你能检查一下吗?你能发布完整的pom吗?
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<workingDirectory>wherever you have your tests</workingDirectory>
<useFile>false</useFile>
<includes>
<include>**/*Spec.groovy</include>
<include>**/*Test.groovy</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<showSuccess>true</showSuccess>
<linkXRef>false</linkXRef>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
</plugin>
</plugins>
</reporting>