TestNG tutorial in simple step-by-step way. This series of TestNG tutorial is based on TestNG 6.9.4.
TestNG is a widely used, popular testing framework which is inspired from JUnit(in Java) & NUnit( in C#) but introducing some new functionalities that make it more powerful and easier to use. While TestNG is becoming a de-facto framework for unit-testing, it is designed to cover all sorts of tests including unit, functional, end-to-end, integration, etc. Let’s begin.
In this tutorial series, we will go through the basic and advanced TestNG practical usage through fully-working code examples, using TestNG with Maven, DBUnit, Mockito and other libraries available, learning best practices. This TestNG tutorial series is based on TestNG 6.9.4
.
TestNG Hello World Example
Very basic hello world example, about how to use TestNG in your project.
TestNG Annotations Example
Commonly used TestNG annotations and their usage.
TestNG Groups Example
TestNG @BeforeGroups, @AfterGroups & group exclusion example.
TestNG Suites Example
TestNG @BeforeSuites, @AfterSuites & @BeforeTest,@AfterTest example.
Maven surefire plugin and TestNG Example
Example about how to run testNG tests using maven. Also discusses in details about testNG suite testng.xml file
TestNG enabled Example
TestNG @Test(enabled=false) example.
TestNG timeOut Example
TestNG @Test(timeOut=XXX) example.
TestNG expectedExceptions Example
TestNG @Test(expectedExceptions=XXX) example.
TestNG dependsOnMethods & alwaysRun Example
TestNG @Test(dependsOnMethods={‘XXX’,’YYY’}, alwaysRun=’true/false’) example.
TestNG dependsOnGroups & alwaysRun Example
TestNG @Test(dependsOnGroups={‘XXX’,’YYY’}, alwaysRun=’true/false’) example.
TestNG @Parameters Example
Example about how to parameterize a test [pass simple parameters to test method] using TestNG @Parameters, @Optional & testNG.xml.
TestNG @DataProvider Example
Example about how to pass complex parameters to tests methods using TestNG @DataProvider.
TestNG Mockito Integration Example
Example post explaining how to use TestNG and Mockito together. We will also learn about stubbing void methods with Mockito.
TestNG DBUnit Example – Testing Data Access Layer
Example post about how to test data access layer in an application using TestNG, DBUnit, H2 database, Mockito & spring-test.