Maven으로 프로젝트를 빌드 할 때마다 실행하고 싶지 않은 데이터베이스에 의존하는 느린 테스트가 있습니다. 내 pom 파일에 http://maven.apache.org/plugins/maven-surefire-plugin/test-mojo.html#excludedGroups 설명한 excludedGroups 요소를 추가 한 있지만 작동시키지 수 없습니다.Maven에서 TestNG 그룹 제외
최소한의 프로젝트를 만들었습니다. 여기에 pom.xml 파일입니다 :
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>exclude</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.4.2</version>
<configuration>
<excludedGroups>db</excludedGroups>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>5.14</version>
</dependency>
</dependencies>
</project>
그리고이 두 테스트 클래스이다 : 그러나 테스트 모두가 여전히 실행
public class NormalTest {
@Test
public void fastTest() {
Assert.assertTrue(true);
}
}
및
public class DatabaseTest {
@Test(groups={"db"})
public void slowTest() {
Assert.assertTrue(false);
}
}
합니다. 나는 내가 뭘 잘못하고 있는지 알 수 없다.
이것은 Maven (실제로 Surefire)의 제한 사항으로 TestNG가 아닌 것으로 보입니다. TestNG 만 사용하면 그룹을 제외하지 않고도 그룹을 제외 할 수 있습니다. –
모든 테스트에 그룹을 추가하고 pom에서 그룹을 지정하려고 시도했지만 아무런 차이가없는 것 같습니다. – samblake
감사합니다. 이것은 저에게 도움이되었습니다. "그룹"과 "제외 된 그룹"은 예상대로 작동 했으므로 함께 사용하거나 단독으로 사용할 수 있습니다. 테스트 대상 : Maven 2.2.1, maven-surefire-plugin 2.4.3, testng 5.14.6. – pestrella