Automation Framework Create Test Script using TestNG
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 do it…
1) Right Click in ‘src/test/java’ –> New –> Package –> name it as ‘com.selenium.test’
2) Right Click in package ‘com.selenium.test’ –> TestNG –> Create TestNG Class.
3) Name your class as ‘autoTestFacebook’ and tick on ‘BeforeTest’ and ‘AfterTest’ option.
4) Double click in ‘autoTestFacebook’ to open it. Copy and paste the code below to this.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
|
5) Right click on your class –> Run As –> TestNG Test.
6) Wait for TestNG running and check the result of test in folder ‘test-output’
Post a Comment
Post a Comment