Sunday, 14 September 2014

TestNG Reporting

TestNG is a testing framework inspired from JUnit and NUnit but introducing some new functionalities that make it more powerful and easier to use. In simple words TestNG is a tool that help us to organize the tests and help us to produce the test reports. TestNG framework can be used for automation testing with Selenium (web application automation testing tool).

TestNG Advantages

  • - Multiple built in Annotations which are easier to use and understand
  • - Test method can be dependent to other method
  • - Test cases can be Grouped and can be execute separately by groups
  • - Parallel testing is possible
  • - TestNG has built in HTML report and XML report generation facility. It has also built in  logging facility

How to use it…

1) First step is to Install TestNG. It is easy to install TestNG, as it comes as a plugin for Eclipse IDE.
2) Create a ‘New Class by right click on the ‘automationFramework‘ package then select TestNGCreate a TestNG Class and name it as TestNG_Framework .
3) Let’s take an example of our previous Log4j_Logging_TC test case and divide the test case in to three parts .
@BeforeMethod : Configure Log4j xml, Open Excel sheet, Launch Firefox and direct it to the Base URL
@Test : Execute SIgnIn action and Log out
@AfterMethod : Close Firefox browser
Note: Method @test has been renamed as main(). By default is f().
3) Run the test by right click on the test case script and select Run As > TestNG Test.
TestNG-FW-1
4) Give it few minutes to complete the execution, once it is finished the results will look like this in the Console window.
TestNG-FW-2
5) Click on the Results of TestNG tab. It will display the total passed, failed and skipped test with time taken during the execution.
TestNG-FW-3
It displayed ‘passed : 1′. This means test is successful and  Passed.
There are 3 sub tabs. “All Tests”, “Failed Tests” and “Summary”. Just click “All Tests” to see what is there.
TestNG-FW-4
6) TestNG also produce HTML reports. To access those reports go to your Project folder and opentest-output folder.
TestNG-FW-5
7) Open ‘emailable-report.html‘, as this is a html report open it with browser.
TestNG-FW-6
8) TestNG also produce ‘index.html‘ report and it resides in the same test-output folder. This reports gives the link to all the different component of the TestNG reports like Groups & Reporter Output. On clicking these will display detailed descriptions of execution. In the advance chapter of TestNG we will go though each of the TestNG topics.
TestNG-FW-7

No comments:

Post a Comment