0

자료 스팍 사양에 대한 스팍 프레임 워크로 작성된 병렬 모드 통합 테스트에서 실행 할 수 있는가하는 것입니다 :봄 부팅

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-failsafe-plugin</artifactId> 
    <version>2.19.1</version> 
    <executions> 
     <execution> 
      <id>integration-tests</id> 
      <phase>integration-test</phase> 
      <goals> 
       <goal>integration-test</goal> 
       <goal>verify</goal> 
      </goals> 
      <configuration> 
       <skip>false</skip> 
       <includes> 
        <include>**/*SpecIT.java</include> 
       </includes> 
       <argLine>-Dfile.encoding=UTF-8</argLine> 
      </configuration> 
     </execution> 
    </executions> 
</plugin> 
:

@SpringBootTest(classes = ApplicationTestConfig.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) 
@TestPropertySource("/application.properties") 
abstract class SpringBootTestSpecification extends Specification { 

프로젝트에 의해 구축되는 안전 장치 - 플러그인을 받는다는 3.3.9

테스트를 병렬 모드로 실행하고 싶지만 다른 애플리케이션에 영향을 미치지 않도록하고 싶습니다 (애플리케이션은 내장 DB로 실행되고 다른 테스트를 위해 다른 데이터를 준비합니다).

답변

0

모든 테스트에 대해 임베디드 DB가 동일하면 (동일한 파일/URL/이름), 잘 리거나 다시 작성 되더라도 하나의 테스트가 실행 중일 수 있으므로 테스트가 예상대로 작동하지 않을 수 있습니다 데이터를 다시 시드하려고 시도하십시오.

어떻게 든 각 테스트가 고유 한 DB에 연결된다면 제 생각에 테스트가 병렬화 될 수 있습니다.

http://maven.apache.org/components/surefire/maven-failsafe-plugin/examples/fork-options-and-parallel-execution.html

JUnit4는 등 메서드, 클래스에 의해을 병렬화하도록 구성되어 있는지 확인합니다 ..

그리고 당신은 호기심을 느낀다면, 몇 달 전에 나는 각각의 테스트에 연결하는 블로그 게시물 Integration Testing using Spring Boot, Postgres and Docker을 발표 a Postgres DB가 다른 컨테이너에서 실행 중입니다. 나는 테스트를 평행하게 다루는 것을 기억하지 못한다.하지만 그것은 실행 가능할 것이다.