Monday, December 26, 2016

TestNG FAQ

My FAQ's
---------
* TestNG
1.
http://www.guru99.com/all-about-testng-and-selenium.html
What is TestNG?
So far we had been doing Selenium tests without generating a proper format for the test results. From this point on,
we shall tackle how to make these reports using a test framework called TestNG.

TestNG is a testing framework that overcomes the limitations of another popular testing framework called JUnit. The "NG" means "Next Generation".
Most Selenium users use this more than JUnit because of its advantages.
There are so many features of TestNG, but we will only focus on the most important ones that we can use in Selenium.

Advantages of TestNG over JUnit
There are three major advantages of TestNG over JUnit:

        Annotations are easier to understand
        Test cases can be grouped more easily
        Parallel testing is possible
Annotations in TestNG are lines of code that can control how the method below them will be executed. They are always preceded by the @ symbol.
A very early and quick example is the one shown below.

* Summary of TestNG Annotations
-------------------------------
@BeforeSuite: The annotated method will be run before all tests in this suite have run.

@AfterSuite: The annotated method will be run after all tests in this suite have run.

@BeforeTest: The annotated method will be run before any test method belonging to the classes inside the tag is run.

@AfterTest: The annotated method will be run after all the test methods belonging to the classes inside the tag have run.

@BeforeGroups: The list of groups that this configuration method will run before. This method is guaranteed to run shortly before the first test method that belongs to any of these groups is invoked.

@AfterGroups: The list of groups that this configuration method will run after. This method is guaranteed to run shortly after the last test method that belongs to any of these groups is invoked.

@BeforeClass: The annotated method will be run before the first test method in the current class is invoked.

@AfterClass: The annotated method will be run after all the test methods in the current class have been run.

@BeforeMethod: The annotated method will be run before each test method.

@AfterMethod: The annotated method will be run after each test method.

@Test: The annotated method is a part of a test case

Conclusion : -
--------------
TestNG is a testing framework that is capable of making Selenium tests easier to understand and of generating reports that are easy to understand.
The main advantages of TestNG over JUnit are the following.
Annotations are easier to use and understand.
Test cases can be grouped more easily.
TestNG allows us to create parallel tests.
The Console window in Eclipse generates a text-based result while the TestNG window is more useful because it gives us a graphical output of the test result plus
other meaningful details such as:
Runtimes of each method.
The chronological order by which methods were executed.
TestNG is capable of generating HTML-based reports.
Annotations can use parameters just like the usual Java methods.

* Reporting:-
-------------
Testng and Junit are the framework; used for reproting.No goog reporting
Junit we do unit testing, extensive support for Qa testing
Log4j configure xml file is used fr the results convertion & Xtent reporting is the jar file used for detail reporting with chart.

No comments:

Post a Comment