1

在一个 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并且我的 grunttest任务将被执行:如果测试通过,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

谢谢

4

1 回答 1

2

不容易。构建失败消息显示失败插件抛出的异常;在exec-maven-plugin的情况下,这将只是退出代码的报告。它不会考虑命令行为中的任何其他内容。

如果您下定决心,您可以重写或扩展exec-maven-plugin,或者在 Groovy 中编写类似的东西来抛出带有更具体消息的异常。

(存在一个grunt-maven-plugin,但它也委托给exec-maven-plugin.)

于 2013-10-05T12:32:47.397 回答