jenkins the definitive guide

(Jeff_L) #1
<include>**/webtests/*.java</include>
</includes>
<excludes>
<exclude>**/pages/*.java</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>

TestNG currently has more flexible support for test groups than JUnit. If you are using TestNG, you
can identify your integration tests using TestNG Groups. In TestNG, test classes or test methods can be
tagged using the groups attribute of the @Test annotation, as shown here:


@Test(groups = { "integration-test" })
public void cashWithdrawalShouldDeductSumFromBalance() throws Exception {
Account account = new Account();
account.makeDeposit(100);
account.makeCashWithdraw(60);
assertThat(account.getBalance(), is(40));
}

Using Maven, you could ensure that these tests were only run during the integration test phase using
the following configuration:


<project>
...
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
<executions>
<execution>
<id>unit-tests</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>false</skip>
<excludedGroups>integration-tests</excludedGroups>¶
</configuration>
</execution>
<execution>
<id>integration-tests</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>false</skip>
Free download pdf