TestNG Framework
TestNG is testing framework inspired from JUnit and NUnit but introducing some more new functionality that makes it more powerful and easier to use. It is open source automated testing framework.
Benefits of TestNG
1. It gives you HTML report of execution.
2. Annotation in TestNG make tester's life easy.
3. Test cases can grouped together and prioritized in well manner.
4. Parallel testing is possible and we can generates logs also by enabling log4j.xml.
Test Case Writing
1. Very first thing is, write the business logic of the test.
2. Use TestNG annotations in the your test code.
3. Add the information about your test (e.g. Class names, methods names, groups names..) in testng.xml file.
4. Once xml is redy with everything run it as TestNG.
Annotations in TestNG
Install TestNG in IntellijIDEA
<suite name="Test-Suite" >
</classes>
TestNG is testing framework inspired from JUnit and NUnit but introducing some more new functionality that makes it more powerful and easier to use. It is open source automated testing framework.
Benefits of TestNG
1. It gives you HTML report of execution.
2. Annotation in TestNG make tester's life easy.
3. Test cases can grouped together and prioritized in well manner.
4. Parallel testing is possible and we can generates logs also by enabling log4j.xml.
Test Case Writing
1. Very first thing is, write the business logic of the test.
2. Use TestNG annotations in the your test code.
3. Add the information about your test (e.g. Class names, methods names, groups names..) in testng.xml file.
4. Once xml is redy with everything run it as TestNG.
Annotations in TestNG
@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.
@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.
@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.
@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.
1. Select Help menu --> click on find action --> enter TestNG --> select TestNG from the listed plugins and install it.
2. After installation and restarting it, just verify if TestNG was needed successfully installed. Right click on your prooject and see if TestNG is dispalyed.
How to run Test Suite using TestNG
No comments:
Post a Comment