2

私がやりたいことは、フェーズ統合テストでテストを実行してから、レポートを生成することだけです。mvn検証によって

ただし、テストのみが実行され、レポートは実行されません。最初のプラグインをコメントすると、他のプラグインが実行されます。それを修正する方法はありますか?

私は私のポンに以下を持っています

<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

この問題は、他のプラグインが実行される前に Maven プロセスをcucumber.api.cli.Main 呼び出して終了させるという事実によるものです。System.exit

この問題を解決する 1 つの方法は、別のプロセスで実行されるため、ゴールではなくのexecゴールを使用することです。exec-maven-pluginjava

ただし、より優れた (そしてより簡単な) 解決策は、キュウリ テストを構成して実行する 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 ブランチで動作しているのを見ることができます。

于 2015-07-13T17:44:59.780 に答える