You have written so many automated scripts in your Testing Framework. When you wrote those scripts inside a main method. To run that particular script, you need to run main method of that particular class.
Let’s assume that we have 100 test scenarios to automate and we developed 100 test scripts using typical style of writing java codes i.e. A class with main method.
- If you want to run all test scripts at once, you need to create a separate runner class where you will call main method of each script class. But it will be very difficult to continue or stop script execution when some scripts fails.
- It is difficult to run a subset of all test scripts or you have dynamic requirements of running scrips. You manually need to write a lot of codes to handle these scenarios.
- Every scenarios can have same or different prerequisites and post requisites conditions. You may need to write duplicate codes repeatedly.
- Establishing relationship or dependencies among test scripts will not be easy task.
- You need to write a good amount of codes to generate a report which will say status of test run.
- Asserting or verifying behavior will require good knowledge of coding.
- Parallel testing, categorization and grouping all will require developer’s effort.
- If new test scripts need to be added, you might fed up in maintenance and modifications.
Above are some scenarios which need extra coding effort. Will it not be good, if you get something which can perform above scenarios and you just need to plug and use? Your problem will be solved. That something is called TestNG.
Just think what is Selenium. Selenium is also a plug and use library or API, which perform what you want like launching a browser or load a URL. You do not need to require to write the codes by your own. TestNG is also similar to Selenium. It is also a jar file, which provides you so many ready made functionalities to use.
As per TestNG official website, “TestNG is a testing framework designed to simplify a broad range of testing needs, from unit testing (testing a class in isolation of the others) to integration testing (testing entire systems made of several classes, several packages and even several external frameworks, such as application servers).”.
TestNG is a framework because it bundles a lot of functionalities in it and provides to end users. Selenium is also a framework.