2015-07-13 2 views
2

Все, что я хочу сделать, это запустить тест в фазе интеграции-теста, а затем сгенерировать отчет. от mvn verifyКонфликт Maven Plugin

Но только проверка выполнена, отчет никогда не запускается. Когда я комментирую первый плагин, тогда выполняется другое. Любая идея, как это исправить?

меня ниже в моем ПОМ

<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-plugin, а не цели 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-plugin или maven-failsafe-plugin плагин выполните этот тест. Плагин maven-cucumber-reporting затем успешно выполнит и создаст отчет.

Вы можете видеть это в действии на github branch I have just pushed.

+0

Спасибо за четкий ответ, который сработал для меня. был настолько расстроен !! – user1344685