在Maven项目中,我使用maven-exec-plugin来启动我的Grunt测试。它是这样的:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>cmd</executable>
<workingDirectory>${project.basedir}/src/main/webapp</workingDirectory>
<arguments>
<argument>/C</argument>
<argument>grunt --no-color test</argument>
</arguments>
</configuration>
</plugin>
</plugins>
</build>
有了它,我可以运行mvn test
,我的咕噜声test
任务将被执行:如果测试通过,maven 构建通过,如果测试失败,maven 构建失败。当某些测试失败时,我有以下输出:
............................................. 1 failing
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.496s
[INFO] Finished at: ** ** ** **:**:** CEST ****
[INFO] Final Memory: *M/*M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (default) on project *****: Command execution failed. Process exited with an error: 6 (Exit value: 6) -> [Help 1]
我想知道是否有可能为失败的测试提供"通常"的 maven 输出。像这样:Build failure, there are failing tests
.
谢谢
不容易。构建失败消息显示失败插件引发的异常;在exec-maven-plugin
的情况下,那只会是退出代码的报告。它不会考虑命令行为中的其他任何内容。
如果你已经下定决心,你可以重写或扩展exec-maven-plugin
,或者也许在Groovy中写一些类似的东西来抛出一个带有更具体消息的异常。
(存在一个 grunt-maven-plugin,但它也委托给 exec-maven-plugin
。