May 2015
Intermediate to advanced
234 pages
4h 18m
English
TestNG, first released in 2004, is the second most popular Java unit testing framework. With most of JUnit features, it also offers parameterized testing (executing a test method with different sets of data) and convenient features for integration testing.
In this recipe, we will write a parameterized test to test the same method as in the previous recipe.
In this recipe, we'll test this simple method (located in the NumberUtil class), which adds two integers:
public static int add(int a, int b) {
return a + b;
}Follow these steps to test a method with TestNG 6:
testng Maven dependency in pom.xml:<dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> <version>6.1.1</version> ...
Read now
Unlock full access