Recent Posts

Saturday, 9 December 2017

TestNG Tutorial



What is Testing?
     Testing is the process of validating and verifying that a piece of software or hardware is working according to the way it’s expected to work. Testing is a very important part of the software development life cycle (SDLC) as it helps in improving the quality of the product developed. There are multiple types and levels of testing, for example, white-box testing, black-box testing, unit testing, integration testing, system testing, acceptance testing, performance testing, security testing, functional testing, non-functional testing, and so on. Each of these testing types are done either manually or through automation, using automation tools.

Introduction of TestNG 
  • TestNG, where NG stands for “Next Generation” is a test automation framework inspired by JUnit (in Java) and NUnit (in C#).  
  • Main purpose of TestNG is to cover all categories of test automation i.e., unit, functional, integration, and end-to-end testing.  
  • TestNG has gained a lot of popularity within a short time and is one of the most widely used testing frameworks among Java developers.  
  • TestNG mainly uses Java annotations to configure and write test methods. 
  • In order to be able to use this TestNG automation framework, you need to have at least a basic knowledge of Java programming language. 
  • TestNG generates the report that is very useful to analyze the application performances.
  • Eliminating most of the limitations of the older framework, TestNG gives the developer the ability to write more flexible and powerful tests.
Features and Advantages of TestNG 
  • TestNG can do a lot more complex automation testing, because of its ability of grouping test cases and executing these groups. For example, if you have defined many test cases and assigned them to 2 different groups, you can execute any particular group passing its name to TestNG. Unlike TestNG, Junit cannot perform Group tests, have objects as parameters, or have dependencies between methods. 
  • In TestNG, no constraint for mandatory annotations (in JUnit @BeforeClass and @AfterClass are mandatory). 
  • There is no constraint for naming TestNG methods. You can give the method an arbitrary name. 
  • In TestNG we can have dependency between methods, while in JUnit it is not possible. 
  • TestNG allows us to create parallel tests. 
  • TestNG support for multi threaded testing.
  • No need to extend any classes. 
  • TestNG has a wider range of SetUp/Teardown annotations, including @Before/AfterSuite, @Before/AfterTest and @Before/AfterGroup. 
  • Asserts, that help us to verify the conditions of the test and decide whether it failed or passed. TestNG supports assertion of a test using the Assert class and assertion plays an important role when performing automation testing on an application. With asserts we can check if two values are equal (assertEquals, assertNotSame), check if the output values exist (assertNotNull), check conditions (assertTrue, assertFalse), etc. 
  • Supports unit testing as well as integration testing.
  • Provides more annotations as compared to JUnit.
  • Integrates very easily with maven and gradle build tools.
  • We can execute tests in particular order.
Next Tutorial  : TestNG Setup

No comments:

Post a Comment