Skip to content

Enhancement: Reliable combination of @Parameters and @DataProvider #3246

@santoshsp17-ops

Description

@santoshsp17-ops

Currently, TestNG does not reliably combine @parameters (from XML) and @dataProvider in all contexts, especially when using:

  • Multiple classes in or
  • Parallel execution (thread-count > 1)

This causes Data provider mismatch errors even when the method signature and DataProvider are correct.

A suggested enhancement is for TestNG to consistently merge XML parameters with DataProvider values in all contexts, similar to how scanning works in simple cases.

Code used -

         @Parameters("URI")
	@Test(dataProvider ="getData")
	public void testDemo(String url, String uname, String pass) {
		System.out.println("Test Demo");
		System.out.println(url);
		System.out.println(uname + " " + pass);
	} 

@DataProvider
		public Object[][] getData() {
			Object[][] data = new Object [3] [2];
			data [0][0] = "firstUser";
			data [0][1] = "firstPass";
			
			data [1][0] = "SecondUser";
			data [1][1] = "SecondPass";
			
			data [2][0] = "ThirdUser";
			data [2][1] = "ThirdPass";
			
			return data;			
		}

Attached testng report & testng4.xml

emailable-report.html

testng4.xml

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions