TestNG Introduction
- TestNG is an open source automated testing framework, where NG of TestNG means NextGeneration.
- Cedric Beust is the creator of TestNG.
- It eliminates most of the limitations of the older framework and gives the developer the ability to write more flexible and powerful tests with help of easy annotations, grouping, sequencing & parameterizing.
Prerequisites: Eclipse and JDK 5 or higher.
We will follow the below steps to install TestNG in Eclipse IDE
There are two ways in installing TestNg in Eclipse
- First Way on installing Eclipse is using “Install new software” option.
- Second way is using “Eclipse Market Place”. – This option will be available in new versions of eclipse.
Benefits of Testng
There are number of benefits of TestNG but from Selenium perspective, major advantages of TestNG are:
- It gives the ability to produce HTML Reports of execution
- Annotations made testers life easy
- Test cases can be Grouped & Prioritized more easily
- Parallel testing is possible
- Data Parameterization is possible
Project structure in detail
- UI Map / Object Repository: UIMap is a concept for defining, storing, and serving UI elements of an application or a website. The UIMap properties file contains a set of ‘key-value’ pairs, where key is an alias of the UI element, and a value is the locator.
- Data Set / Test Data: Data set stores the data files, Script reads test data from external data sources and executes test based on it. Data sets increases test coverage by performing testing with various inputs and reduce the number of overall test scripts needed to implement all the test cases.
- Test Automation Scripts: A test is considered as a single action or a sequence of actions, that defines whether a specific feature meets functional requirements.
- Reports / Executed Results: Test report/results is a document which contains summary of test activities.
- TestNG xml file: In order to create a test suite and run separate test cases, we need framework which drives the automation. Advantage of using TestNG with Selenium is of running multiple test cases from multiple classes using xml configuration file.