2007년 10월 18일
maven test
テストする
カレントにpom.xmlのある状態で
mvn test
を実行する。実行すると src/test/java 以下の
- **/*Test*.java
- **/Test*.java
- **/*TestCase?.java
にマッチするファイルをJunitのテストとして実行する。なお
- **/Abstract*Test.java
- **/Abstract*TestCase?.java
はデフォルトで無視する。
ビルド時、テストフェーズをスキップする
mvnコマンドに、 -Dmaven.test.skip=true を加える。
また、settings.xmlに定義して常にテストフェーズをスキップする。
<settings>... <profiles> <profile> <id>notTest</id> <properties> <maven.test.skip>true</maven.test.skip> </properties> </profile> </profiles> <activeProfiles> <activeProfile>notTest</activeProfile> </activeProfiles></settings>
特定のクラスだけテストする
mvn test -Dtest=テストクラス名
mvn testコマンドに-Dtest=FooBarTest?のようにテストクラスを指定する。-Dtest=*UtilTest?,*DaoTest?のように、カンマ区切りの正規表現でも指定できる。
また、デフォルトのフィルタ設定を変更したい場合は、maven-surefire-pluginを利用して設定を記述する。pom.xmlに以下を追記。
<build>... <pluginManagement> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <includes> <include>**/*Test.java</include> </includes> </configuration> </plugin> </plugins> </pluginManagement></build>
# by | 2007/10/18 12:35 | 기타 | 트랙백 | 덧글(0)





☞ 내 이글루에 이 글과 관련된 글 쓰기 (트랙백 보내기) [도움말]