単体テストの依存関係を削除したいと思います。この回答でその方法を見つけました。
しかし、すべてのテストではなく、特定の 1 つのテストのみの依存関係を削除したいと考えています。それを行う方法はありますか?
単体テストの依存関係を削除したいと思います。この回答でその方法を見つけました。
しかし、すべてのテストではなく、特定の 1 つのテストのみの依存関係を削除したいと考えています。それを行う方法はありますか?
Surefireの実行を1つ使用することによってではありません。
Surefire プラグインの 2 つの実行を定義する必要があります。1 つはほとんどのテスト用の完全なクラスパスを含み、もう 1 つはそれを必要とする単一のテスト用の特別なクラスパスを含みます。
Surefire プラグインのドキュメントに従ってください: http://maven.apache.org/surefire/maven-surefire-plugin/examples/inclusion-exclusion.html
test
2 つの実行を作成し、両方をフェーズにバインドする必要があります。次の例をスケルトンとして使用します (パターンinclude
とexclude
パターン、および除外されたクラスパス アーティファクトを調整する必要があります)。
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<executions>
<execution>
<id>full-cp</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<includes>
<include>**/Test*.java</include>
</includes>
<excludes>
<exclude>MyFancyTest.java</exclude>
</excludes>
</configuration>
</execution>
<execution>
<id>special-cp</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<includes>
<include>MyFancyTest.java</include>
</includes>
<classpathDependencyExcludes>
<classpathDependencyExcludes>excluded-artifact</classpathDependencyExcludes>
</classpathDependencyExcludes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>