2015-07-13 100 views
2

我想要做的就是在阶段整合测试中运行测试,然后生成报告。 由mvn验证Maven插件冲突

但只有测试执行报告从不运行。当我评论第一个插件,然后执行其他。任何想法如何解决它?

下面我有我的POM

<build> 
    <plugins> 
     <plugin> 
      <groupId>org.codehaus.mojo</groupId> 
      <artifactId>exec-maven-plugin</artifactId> 
      <version>1.4.0</version> 
      <executions> 
       <execution> 
        <phase>integration-test</phase> 
        <goals> 
         <goal>java</goal> 
        </goals> 
        <configuration> 
         <classpathScope>test</classpathScope> 
         <executableDependency> 
          <groupId>info.cukes</groupId> 
          <artifactId>cucumber-core</artifactId> 
         </executableDependency> 
         <mainClass>cucumber.api.cli.Main</mainClass> 
         <arguments> 
          <argument>target/test-classes/feature</argument> 
          <agrument>--glue</agrument> 
          <argument>integration</argument> 
          <argument>src\test\java</argument> 
          <argument>--plugin</argument> 
          <argument>pretty</argument> 
          <argument>--plugin</argument> 
          <argument>html:target/cucumber-report</argument> 
          <argument>--plugin</argument> 
          <argument>json:target/cucumber-report/cucumber.json</argument> 
          <argument>--tags</argument> 
          <argument>[email protected]</argument> 
         </arguments> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 
     <plugin> 
      <groupId>net.masterthought</groupId> 
      <artifactId>maven-cucumber-reporting</artifactId> 
      <version>0.0.8</version> 
      <executions> 
       <execution> 
        <phase>verify</phase> 
        <goals> 
         <goal>generate</goal> 
        </goals> 
        <configuration> 
         <projectName>poc.selenium.it</projectName> 
         <outputDirectory>target/cucumber-report</outputDirectory> 
         <cucumberOutput>target/cucumber-report/cucumber.json</cucumberOutput> 
         <enableFlashCharts>true</enableFlashCharts> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 
    </plugins> 
</build> 

回答

0

这个问题是由于这样的事实:cucumber.api.cli.Maincalls System.exit,因此终止Maven的过程之前,其他插件获取执行。

解决此问题的一种方法是使用exec-maven-pluginexec目标,而不是目标java,因为它在单独的过程中运行。

然而,一个更好的(更容易)解决方案是定义一个JUnit测试,它配置和运行黄瓜测试,例如:

package integration; 

import org.junit.runner.RunWith; 

import cucumber.api.junit.Cucumber; 
import cucumber.api.CucumberOptions; 

@RunWith(Cucumber.class) 
@CucumberOptions(plugin = "json:target/cucumber-report/cucumber.json") 
public class RunTest { 
} 

然后,您可以使用该maven-surefire-pluginmaven-failsafe-plugin插件执行该测试。然后,maven-cucumber-reporting插件将成功执行并创建报告。

您可以在github branch I have just pushed上看到此操作。

+0

感谢您的明确答案,为我工作。非常沮丧! – user1344685