[英]Ignore a module during maven test build for multi module maven project
是否可以在多模塊maven項目中運行maven測試版本( mvn clean test
)並跳過/忽略特定模塊的測試? 像-Dmaven.test.skip=true
但是對於特定模塊而不是所有模塊? 我不想更改<skipTests>true</skipTests>
<configuration>
以包含<skipTests>true</skipTests>
為我想要跳過測試的模塊。 我想知道是否可以從命令行完成此操作。 我需要這個,因為在我的項目中我有很多模塊,特別是一兩個需要很長時間才能執行測試,所以當我只想測試幾個模塊時,我想跳過這些時間我不需要模塊做了任何改變。
更改surefire插件的配置真的是一個問題嗎? 因為您只能在模塊中更改一次...
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
<configuration>
<skipTests>${skip.foo.module.tests}</skipTests>
</configuration>
</plugin>
</plugins>
</build>
...並將skipTests標記的true / false值委托給由專用配置文件激活的maven屬性:
<properties>
<skip.foo.module.tests>false</skip.foo.module.tests>
</properties>
<profiles>
<profile>
<id>SKIP_FOO_MODULE_TESTS</id>
<properties>
<skip.foo.module.tests>true</skip.foo.module.tests>
</properties>
</profile>
</profiles>
這樣您就可以使用命令行在Foo模塊中停用測試:
mvn clean test -P SKIP_FOO_MODULE_TESTS
您可以使用配置了surefire跳過的配置文件來完成此操作。 這允許您在大多數時間保持測試運行,但是當您想要在某個時間跳過其中一個模塊的測試時,您可以調用該配置文件。 然后,您可以使用跳過測試排除所有測試,或者可以使用excludes選項僅排除長時間執行的一個或兩個測試。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.