A Brief Introduction To TestNG Framework

Posted By : Neha Dahiya | 22-Feb-2018

What is TestNG?

TestNG is a testing framework where “NG” stands for “Next Generation” which helps to generate a proper format of the test results. TestNG framework overcomes the drawbacks of one of the popular testing framework known as Junit. Because of its advantages, nowadays TestNG framework is used frequently.

 

Major Advantages of TestNG

 

Annotations are basically the lines of code which controls how the functions will be executed. “@” symbol is used before a annotation. Follow the example:

 

 

Output of the above Code:

 

 

 

The above example states that the method with priority “1” will be executed before the method with priority “7”. Annotations are easily implemented in TestNG then in Junit framework, it can be seen in the above example.

Priority can be defined as : “0” has the highest priority and so on. TestNG framework is the most prefered framework as test can be executed parallely but the same cannot be done in Junit framework.

 

Methods having same Priority

 

There may be case in which two methods have the same priority then in that case alphabet order  of the method name is considered.

 

Consider the following example:

 

 

Output of the above code:

 

 

Conclusion:

 

TestNG framework helps in making tests easier for generating and understanding the reports.

 

The main advantage of testNG over Junit framework is :

 

Grouping of Selenium test cases can be done easily.

     Easier to use and understand Annotations.

     Parallel tests can be created.

TestNG Console Window provides a graphical output of the result of tests and the additional details such as the chronological order of the methods executed and annotations can be used in the usual way such as the Java methods works.

 

HTML based reports can be easily generated in TestNG framework.

 

TestNG supports multiple instances for same test class.

 

 

Thanks!!

 


 

 
Related Tags

About Author

Author Image
Neha Dahiya

Neha is a bright QA Engineer with skills in manual testing . Apart from finding bugs in application, she loves sketching and painting.

Request for Proposal

Name is required

Comment is required

Sending message..