TestNG is a unit-testing framework for Java that uses Java annotations, allowing complex test libraries to be built up. TestNG test suites can be developed entirely separately from your application's source code, and therefore do not have to be deployed with applications.
TestNG test suites are built up from classes that are adorned with different annotations. Let's take a look at a basic test class:
package mytests; import org.testng.annotations.* public class ATest { @Test (groups= {"examples"}) public void runATest() { assert getString().equals("some value"); } }
This simple test class (ATest
) defines a test class that has one test method (runATest
). The method we wish to run as a test is adorned with the @Test
annotation.
@Test (groups= {"examples"})
This annotation takes an array of the different groups that the test is defined as belonging to. In this example, the test belongs to the examples
group. The groups
parameter is optional, but can be used to differentiate different groups...