LambdaTest Community

Find answers, support, and inspiration from other users

Questions
LambdaTest Community
Answered

How can I perform parameterization using TestNG?

Please tell me how to perform parameterization using TestNG?

Up Vote Down Vote 0 Votes
Posted 3 months ago

Answers


In the real world for web UI testing, we expect our website or web application to work correctly with varied inputs and it is practically not possible to validate our scenarios with just a single data set. So we ensure that our application is functioning as expected when exposed to different data sets or different combinations for browsers and OS. Multiple test combinations mean multiple input values.

Now, you cannot hardcode test values every time in your test automation scripts, otherwise making one change will require you to edit many test automation scripts. That’s where Parameterization in TestNG or any other comes into the picture and the reason why we parameterize our Selenium automation testing scripts is to provide different data sets to our web application at runtime.

How Do We Perform Parameterization? And Why Use TestNG?

If your application involves inputting different types of user interactions, then Parameterization is the way to go. We can parameterize our automation scripts as per the framework being used for example Parameterization in TestNG framework for Selenium automation testing. We can consider using excel files to fetch data sets and subsequently use it in our automation scripts but as we enhance our automation suite, it becomes necessary to use more robust test automation frameworks like TestNG to cover a wide category of tests in a more powerful manner. In this post, we will be focussing mainly on Parameterization in TestNG, what ways can it be achieved in TestNG and how do we go about writing these parameters in our Selenium automation testing scripts. Let us first begin with understanding the different types of Parameterization in TestNG and how can we achieve the same.

Types of Parameterization in TestNG

So primarily we can achieve parameterization in TestNG in two ways.

Using “Parameters annotation” and TestNG XML file. Using “DataProvider annotation”.

Up Vote Down Vote 0 Votes
Posted 3 months ago