我想使用Maven的Spring Boot測試集成功能。當我運行的下一個命令我看到它不工作如我所料:Maven-failsafe-plugin:skipTests配置不適用於Spring Boot 1.4集成測試
mvn clean install -DskipIntegrationTests=true
它開始運行集成測試,但應該跳過他們。 我的問題是:
- 我該如何控制集成測試執行與maven?
- 我真的需要一個maven-failsafe插件嗎?
注:我使用的彈簧引導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
}
}
與正常單元測試相比,您如何將該測試識別爲「集成測試」? –
我不認同,可能是我錯過了一些maven插件配置 – Dimon