2013-10-01 29 views
0

在Maven项目中,我使用maven-exec-plugin来启动我的Grunt测试。它是这样的:正确绑定maven exec插件到测试阶段

<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] 

我想知道是否有可能有失败的测试的“常态”行家输出。例如:Build failure, there are failing tests

谢谢

回答

2

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

如果确定,您可以重写或扩展exec-maven-plugin,或者在Groovy中编写类似的代码,以便使用更具体的消息来引发异常。

(A grunt-maven-plugin存在,但它也代表们exec-maven-plugin

+0

是啊,这就是我担心。感谢指向'grunt-maven-plugin'的指针,尽管我更喜欢使用'exec-maven-plugin'。 – htulipe

相关问题