2

What all i want to do is run test in phase integration-test and then generate report. by mvn verify

But only test are executed report never runs. When i comment first plugin then other is executed. Any idea how to fix it?

I have below in my 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>~@ignore</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>
4

1 回答 1

0

问题是由于在执行其他插件之前cucumber.api.cli.Main 调用并因此终止了 Maven 进程。System.exit

解决问题的一种方法是使用 的exec目标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-pluginmaven-failsafe-plugin插件来执行该测试。然后maven-cucumber-reporting插件将成功执行并创建报告。

你可以在我刚刚推送的 github 分支上看到这一点。

于 2015-07-13T17:44:59.780 回答