You might be asked in selenium interviews, “Why TestNG is called a testing framework?”.
Why TestNg is called “Testing Framework“?
TestNG, where NG stands for “Next Generation”. TestNG is a testing framework to perform unit, functional, end-to-end, integration, etc testing. This library helps you in writing automated tests.
Suppose, you are launching a URL and you need to verify the title of page. If you are a manual tester, you will load the URL and will verify the page title. As part of smoke and sanity, you keep loading URL and verifying title of the page. When new modules are integrated and installed, you again verify title. When all modules are integrated, you need to verify again and as per daily smoke, you need to do the same task again and again.
Now as an automation tester, you create some logic to verify title of the page using Selenium. And you run you script file whenever you need to verity the page title. You can create so many script files which verify something and run. Sometimes you may need to run all scripts or scripts related to specific group. All these might be difficult for an automation tester to manage.
Here, TestNG comes in to picture, saying you just organize your test methods or add some specific information using our annotations to your test methods and handle all types of customization execution from a single file called “testng.xml”. TestNG allows you to control when to run which tests.
Writing a test is typically a three-step process:
- Write the business logic of your test and insert TestNG annotations in your code.
- Add the information about your test (e.g. the class name, the groups you wish to run, etc…) in a testng.xml file or in build.xml.
- Run TestNG.
TestNG is used by developers and testers both. Developers use it for unit testing and we testers can use it for whatever testing we want to do. Since, TestNG are designed to automate control of testing activities, it is called a Testing Framework.
More about TestNG in upcoming posts. Stay tuned.
If you have any doubt, feel free to comment below.
If you like my posts, please like, comment, share and subscribe.