19

JUnit4テストの一部に@Categoryアノテーションを付けるつもりです。次に、そのカテゴリのテストをMavenビルドでの実行から除外したいと思います。

Mavenのドキュメントから、実行するテストのカテゴリを指定できることがわかりました。実行しないテストのカテゴリを指定する方法を知りたいです。

ありがとう!

4

1 に答える 1

24

これは次のように実行できます。

pom.xmlには、次の設定が含まれている必要があります。

<configuration>
   <excludes>
       <exclude>**/TestCircle.java</exclude>
        <exclude>**/TestSquare.java</exclude>
   </excludes>
</configuration>

正規表現のサポートが必要な場合は、

<excludes>
    <exclude>%regex[.*[Cat|Dog].*Test.*]</exclude>
</excludes>

http://maven.apache.org/surefire/maven-surefire-plugin/examples/inclusion-exclusion.html

カテゴリアノテーションを使用する場合は、次のことを行う必要があります。

@Category(com.myproject.annotations.Exclude)
@Test
public testFoo() {
   ....
}

Maven構成では、次のようなものを使用できます

<configuration>
  <excludedGroups>com.myproject.annotations.Exclude</excludedGroups>
</configuration>
于 2013-01-03T04:22:12.507 に答える