[英]Maven-failsafe-plugin: skipTests configuration does not work for Spring Boot 1.4 integration tests
我想在Maven中使用Spring Boot測試集成功能。 當我運行下一個命令時,我發現它沒有按預期運行:
mvn clean install -DskipIntegrationTests=true
它開始運行集成測試,但應跳過它們。 我的問題是:
注意:我正在使用Spring Boot 1.4.0.RELEASE我的POM:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>integration-test</goal>
</goals>
<configuration>
<skipTests>${skipIntegrationTests}</skipTests>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
我的整合測試:
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ActiveProfiles("development")
@SqlGroup({
@Sql(executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, scripts = "classpath:beforeTestRun.sql"),
@Sql(executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD, scripts = "classpath:afterTestRun.sql")
})
public class AdminTest {
@Autowired
private TestRestTemplate restTemplate;
@Test
public void get_all_admins() {
//TODO: code here
}
}
您將需要看一下故障安全插件的工作方式。 具體來說,它是如何識別應該屬於集成測試階段的測試的:
http://maven.apache.org/surefire/maven-failsafe-plugin/examples/inclusion-exclusion.html
默認情況下,故障安全插件將自動包含具有以下通配符模式的所有測試類:
**/IT*.java
包括其所有子目錄和所有以“ IT”開頭的Java文件名。**/*IT.java
包括其所有子目錄和所有以“ IT”結尾的Java文件名。**/*ITCase.java
包括其所有子目錄和所有以“ ITCase”結尾的Java文件名。如果測試類未遵循任何這些命名約定,則配置故障保護插件並指定要包括的測試。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.