jenkins the definitive guide

(Jeff_L) #1

Figure 6.9. Jenkins also lets you see how long your tests take to run


Skipping some tests is perfectly legitimate in some circumstances, such as to place an automated
acceptance test, or higher-level technical test, on hold while you implement the lower levels. In such
cases, you don’t want to be distracted by the failing acceptance test, but you don’t want to forget that the
test exists either. Using techniques such as the @Ignore annotation are better than simply commenting
out the test or renaming it (in JUnit 3), as it lets Jenkins keep tabs on the ignored tests for you.


In TestNG, you can also skip tests, using the enabled property:


@Test(enabled=false)
public void cashWithdrawalShouldDeductSumFromBalance() throws Exception {
Account account = new Account();
account.makeDeposit(100);
account.makeCashWithdraw(60);
assertThat(account.getBalance(), is(40));
}

In TestNG, you can also define dependencies between tests, so that certain tests will only run after
another test or group of tests has run, as illustrated here:


@Test
public void serverStartedOk() {...}

@Test(dependsOnMethods = { "serverStartedOk" })
Free download pdf