0

テストを3つの異なるカテゴリに分けたい:

  • 単位
  • componnet
  • システム

次に、それらを異なるフェーズで別々に実行し、これらのテストの実行結果を3つの異なる確実なレポートに表示します。または1つですが、テスト結果を3つの異なるカテゴリに分割します。

Mavenでそれを達成する方法は?

フェイルセーフMavenプラグインを使用してテストを個別に実行できることはわかっています。ですから問題ありません。

唯一の問題は、レポートを3つのカテゴリに分類できることです。

4

1 に答える 1

3

私はjunitカテゴリでmaven-surefire-pluginを使用しています。

    <plugin>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.12.2</version>
            <executions>
                <execution>
                    <id>unit-tests</id>
                    <goals>
                        <goal>test</goal>
                    </goals>
                    <configuration>
                        <groups>com.mycompany.mavenproject2.UnitTest</groups> 
                        <reportsDirectory> ${project.build.directory}/surefire-reports/unit</reportsDirectory> 
                        <reportNameSuffix>UNIT</reportNameSuffix>      
                    </configuration>     
                </execution>
                <execution>
                    <id>comp-tests</id>
                    <goals>
                        <goal>test</goal>
                    </goals>
                    <configuration>
                        <groups>com.mycompany.mavenproject2.ComponentTest</groups>
                        <reportsDirectory> ${project.build.directory}/surefire-reports/comp</reportsDirectory> 
                        <reportNameSuffix>COMPONENT</reportNameSuffix>                
                    </configuration>     
                </execution>
                <execution>
                    <id>sys-tests</id>
                    <goals>
                        <goal>test</goal>
                    </goals>
                    <configuration>
                        <groups>com.mycompany.mavenproject2.SystemTest</groups>
                        <reportsDirectory> ${project.build.directory}/surefire-reports/sys</reportsDirectory>
                        <reportNameSuffix>SYSTEM</reportNameSuffix>                  
                    </configuration>     
                </execution>
            </executions>
        </plugin>

カテゴリに分けずにすべてのテストを最初に実行することを除いて、正常に動作します。 そのような行動を取り除く方法は?

ビルドは出力を生成しました。

テスト

com.mycompany.mavenproject2.AppTestの実行UnitTestComponentTestSystemTestテストの実行:3、失敗:0、エラー:0、スキップ:0、経過時間:0.031秒

結果 :

実行されるテスト:3、失敗:0、エラー:0、スキップされた:0

[surefire:test] Surefireレポートディレクトリ:C:\ Users \ mz \ Documents \ NetBeansProjects \ mavenproject2 \ target \ surefire-reports \ unit


テスト

同時実行構成はparallel='none'、perCoreThreadCount = true、threadCount = 2、useUnlimitedThreads = falseです。com.mycompany.mavenproject2.AppTestの実行UnitTestテストの実行:1、失敗:0、エラー:0、スキップ:0、経過時間:0.003秒

結果 :

実行されるテスト:1、失敗:0、エラー:0、スキップされた:0

[surefire:test] Surefireレポートディレクトリ:C:\ Users \ mz \ Documents \ NetBeansProjects \ mavenproject2 \ target \ surefire-reports \ comp


テスト

同時実行構成はparallel='none'、perCoreThreadCount = true、threadCount = 2、useUnlimitedThreads = falseです。com.mycompany.mavenproject2.AppTestComponentTestの実行テストの実行:1、失敗:0、エラー:0、スキップ:0、経過時間:0.003秒

結果 :

実行されるテスト:1、失敗:0、エラー:0、スキップされた:0

[surefire:test] Surefireレポートディレクトリ:C:\ Users \ mz \ Documents \ NetBeansProjects \ mavenproject2 \ target \ surefire-reports \ sys


テスト

同時実行構成はparallel='none'、perCoreThreadCount = true、threadCount = 2、useUnlimitedThreads = falseです。com.mycompany.mavenproject2.AppTestの実行SystemTestテストの実行:1、失敗:0、エラー:0、スキップ:0、経過時間:0.003秒

結果 :

実行されるテスト:1、失敗:0、エラー:0、スキップされた:0

于 2012-08-17T12:10:40.263 に答える