테스트 및 통합 테스트를 위해 다른 그룹과 함께 Maven SureFire 플러그인을 사용하는 방법은 무엇입니까?
-
03-07-2019 - |
문제
사용하고 싶습니다 testng 이랑 확실한 플러그인 의 Maven. 아이디어는 그룹과 일부 테스트를 태그하는 것입니다. integrationTest
플러그인을 두 번 실행하십시오 : 목표 test
그룹 제외 integrationTest
그리고 목표를 위해 integration-test
그룹을 포함하여 integrationTest
뿐.
나는 일부를 찾았다 재료 두 목표와 그 작동에 대한 플러그인을 실행하려면 두 번째 달리기 그룹은 작동하지 않습니다 (테스트는 실행되지 않음).
다음은 내 빌드 요소의 플러그인 구성입니다. pom.xml
:
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludedGroups>integrationTest</excludedGroups>
<reportFormat>brief</reportFormat>
<trimStackTrace>true</trimStackTrace>
<useFile>false</useFile>
</configuration>
<executions>
<execution>
<id>integration-test</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<groups>integrationTest</groups>
<excludedGroups/>
<reportsDirectory>${project.build.directory}/surefire-reports/integration</reportsDirectory>
</configuration>
</execution>
</executions>
</plugin>
아이디어가 있습니까? mvn integration-test
예상대로 모든 단위 테스트를 실행합니다 (그룹 제외 integrationTest
)하지만 두 번째 테스트 실행은 다음과 같습니다.
실행 테스트 수양
테스트 실행 : 0, 실패 : 0, 오류 : 0, 건너 뛰기 : 0, 시간 경과 : 0.562 sec
결과 mvn test
예상대로 테스트가 실행되고 그룹화됩니다 integrationTest
무시됩니다.
해결책
나는 그것을 얻었다 - 자극적 구성 구현!
<excludedGroups/>
무시하지 않습니다 <excludedGroups>integrationTest</excludedGroups>
. 대신 (알 수없는) 그룹을 지정해야합니다. <excludedGroups>none</excludedGroups>
예를 들어.
다른 팁
그만큼 실패 플러그인 이 작업을 수행하는 가장 좋은 방법입니다 (이 질문을 게시 할 때는 사용할 수 없었을 수 있음). 빌드 라이프 사이클에 통합 테스트 단계를 추가합니다. 예를 들어 임베디드 컨테이너를 관리하는 데 유용합니다.