@Category
アノテーションで使用されるプロジェクト全体のインターフェイスを定義し、プロジェクト全体をビルドするときにアノテーション付きのテストを除外するように Maven を構成したいと思います。
アプリケーションプロジェクトには、分類したいテストがあります。
@Category(Integration.class)
@Test
public void testExternalResource() { ... }
設定:
マルチモジュールのmavenプロジェクトをセットアップしました:
/container (has a pom with <modules> element)
/parent (all other modules inherit from its pom. has no source, only pom)
/util (other modules are depending on it)
/infra
/application (depending on infra and util, inherits from parent)
インフラストラクチャフリークです:)、モジュール内のグループを除外するようにプロジェクト全体を構成したいと思います。だから、私が定義した親モジュールで:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
<configuration>
<excludedGroups>com.mycompany.test.Integration</excludedGroups>
</configuration>
</plugin>
そして、すべてのモジュールが表示できるように、Integration
インターフェイスをutilモジュール ( 内) に配置しました。util/src/test/java
package com.mycompany.test;
public interface Integration {}
であるためtest-jar
、utilとapplicationの両方に適切な構成を作成しました。
エラー:
を実行するmvn clean install
と、取得しています
[ERROR] Failed to execute goal org.apache.maven.plugins:
maven-surefire-plugin:2.16:test
(default-test) on project util: Execution default-test of goal
org.apache.maven.plugins:maven-surefire-plugin:2.16:test
failed: There was an error in the forked process
[ERROR] java.lang.RuntimeException:
Unable to load category: com.mycompany.test.Integration
もちろん、このクラスは利用できません。プロジェクトの最初のモジュールのテスト jar に詰め込みました。:(
Integration
mvn 構成とソース コードで使用できるようにするには、インターフェイスをどこに配置すればよいですか?