Make Selenium Easy

TestNG Tutorials 43: Difference Between “Parameters” and “parameter” in TestNG

Hello Folks,

I was asked this question in an interview and I was like “Are there two terms “Parameters” and “parameter” in TestNG?“.

Yes, There are two different terms, “Parameters” and “parameter. We have used both termas many times but didn’t notice minor thing.

“Parameters” is an annotation which allows us to create parameterized methods in a TestNG class. For example:

public class ParametersThroughXML {

	/* We need to add Parameters annotation to read value from testng xml. Note here that
	 * attribute name passed in Parameters must be same as testng xml. 
	public void configurationBeforeMethod(String confBeforeParameter)
		System.out.println("Paramters for before configuration method: "+confBeforeParameter);
	public void testMethod(String testParameters1, String testParameters2)
		System.out.println("Paramters one for test method: "+testParameters1);
		System.out.println("Paramters two for test method: "+testParameters2);
	public void configurationAfterMethod(String confAfterParameter)
		System.out.println("Paramters for after configuration method: "+confAfterParameter);

“parameter” is a tag which is used to pass values to parameterized methods of a TestNG class. Example:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "">
<suite name="Suite">
	<test thread-count="5" name="Test">
		<parameter name="confBeforeParameter" value="confBeforeParameter" />
		<parameter name="testParameters1" value="testParameters1" />
		<parameter name="testParameters2" value="testParameters2" />
		<parameter name="confAfterParameter" value="confAfterParameter" />
			<class name="Parameters.ParametersThroughXML" />
	</test> <!-- Test -->
</suite> <!-- Suite -->

Hopefully, you will not be surprised if you face above question. Answer like a pro.

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.


Table of Contents

Author: Amod Mahajan

A software Tester who is paid to judge products developed by others. Currently getting paid in American Dollars. Writing technical posts and creating YouTube videos are my hobbies.

Leave a Reply

Please wait...

Subscribe to new posts to become automation expert

Want to be notified when my new post is published? Get my posts in your inbox.

TestNG Tutorials 43: Difference Between “Parameters” and “parameter” in TestNG

by Amod Mahajan time to read: 1 min
%d bloggers like this: