2015-07-13 112 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