TestNG is a testing framework stirred from NUnit and JUnit but presenting some new functionalities that make it much easier and powerful to use. It is an open source automated testing framework; in which NG means Next Generation. TestNG is much more influential than JUnit but is inspired by JUnit. It is developed to be better than JUnit, specifically while testing integrated classes. We should thank Cedric Beust who has created TestNG.
2. TestNG is a testing framework stirred from NUnit and JUnit but
presenting some new functionalities that make it much easier
and powerful to use. It is an open source automated testing
framework; in which NG means Next Generation. TestNG is much
more influential than JUnit but is inspired by JUnit. It is
developed to be better than JUnit, specifically while testing
integrated classes. We should thank Cedric Beust who has
created TestNG.
3. TestNG removes most of the limitations of the older framework
and gives the developer the facility to write more powerful and
flexible tests with help of easy grouping, annotations,
parameterizing and sequencing.
4. Benefits of TestNG
There are a large number of advantages but from Selenium
perspective, the major advantages of TestNG are:
1. It gives the facility to produce HTML Reports of
implementation.
2. Annotations have made testers’ life easier.
3. Test cases can be Prioritized and Grouped more easily.
4. It makes Parallel testing easier.
5. Logs can be generated.
6. It makes Data Parameterization possible.
5. TestNG Framework Features
TestNG contains many powerful features and it is quite easy to
use. Let’s see what all new features are supported in new
testing framework:
1. There is a full support for parameters.
2. It supports testing of dependent methods.
3. Test configuration is quite flexible.
4. It also supports powerful implementation model.
5. TestNG embeds BeanShell for advanced flexibility.
6. TestNG has a more clear way of supervising parameterized
tests with the data provider concept.
7. For the same test class, TestNG supports multiple
occurrences.
6. 8. Extendibility of using different plug-ins and Tools like
Maven, Eclipse, IDEA etc.
9. Default JDK functions for logging and runtime without any
dependency.
10. Supported different Annotations like @AfterSuite,
@BeforeSuite, @AfterClass, @BeforeClass, @AfterTest,
@BeforeTest, @AfterGroups, @BeforeGroups,
@AfterMethod, @BeforeMethod, @Factory,
@DataProvider, @Parameters, @Test, @Listeners.
7. TestNG supports annotations which are quite helpful to
guide test case executions. The TestNG annotations are
always headed by the ‘@’ symbol. It authorizes you to do
parallel execution of test cases and we can also skip the test
cases smoothly while implementing test cases.
8. TestNG is specially designed to cover all types of testing categories
like Functional testing, Unit testing, End-to-end, Integration testing
etc. TestNG framework allows us to produce test reports in both
XML and HTML formats. Using ANT with TestNG, we can produce
primitive TestNG reports as well.
9. Benefits of TestNG over Junit
1. In TestNG, Annotations are easy to understand but not in
JUnit.
2. In TestNG, there is no constraint like you have to state
@AfterClass and @BeforeClass, which is present in JUnit.
3. You can specify any test method names in TestNG as
method’s name constraint is not present in TestNG like it
is in JUnit.
4. TestNG allows you to group the test cases effortlessly
which is not possible in JUnit.
5. TestNG supports following three 3 additional teardown/
setUp levels: @Before/AfterTest, @Before/AfterGroup
and @Before/AfterSuite.
10. 6. TestNG does not require any class Extensions.
7. TestNG permits us to define that each test case is
independent of the other test case.
8. TestNG lets us implement test cases based on groups. Let’s
take a scenario where we have created two set of groups
“Sanity” and “Regression”. If we want to implement the
test cases under Sanity group then it is possible in TestNG
framework.
9. Parallel implementation of Selenium test cases is possible
in TestNG.