![](/img/trans.png)
[英]How to run integration tests in UAT where the output is a jms message to a queue consumed by another service?
[英]How to make jenkins run integration tests only when deploying to UAT?
我正在使用 jenkins 並且我有一個staging > qa > uat > master environment set.
我不希望 jenkins 在暫存和質量檢查環境中運行任何集成測試,僅針對 uat 和 master。
有可能這樣做嗎? 如果是這樣,如何? 我的意思是,我應該將單元測試和集成測試分開放在不同的包中嗎? 今天我有:
src/main/java
src/test/java
定義接口 IntegrationTest
public interface IntegrationTest {}
並使用 Junit4 中的注釋@Category
將您的測試分類為集成測試。
@Category(IntegrationTest.class)
public class YourTest
因此,請使用 maven surefire
和failsafe
插件來創建睾丸組。
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludedGroups>you.package.IntegrationTest</excludedGroups>
</configuration>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<includes>
<include>**/*.java</include>
</includes>
<groups>you.package.IntegrationTest</groups>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
集成測試將自動從默認執行中排除,即 mvn clean package。但是,如果您運行mvn integration-test
,所有集成測試都將運行。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.