2

I use in my framework testNG with Data driven. All test data are taken from excel table and DataDriven return them as a two dimensional array e.g. Data[][].

My code looks like:

@Test (DataDriven = "data")
public void testCase(Sting testName, String testData1, String results){
    String s = doSomething(testData1);
    Assert.assertTrue(s, results);

This is only an example, but every test parameter I got from excel column. I would like to add to testate name a name from testName parameter. Is it even possible? I use additionally Listener with ITestListener interface.

Gautham M
  • 4,816
  • 3
  • 15
  • 37
Kamil
  • 77
  • 6
  • are you saying that each test case should be run with different test names? – Gautham M Aug 24 '21 at 05:16
  • Yes. I will change not only test name but test method name. I found a solution, where you can change test instance name, but the test name in html or xml output report is still untouched. Only test instance names are different. – Kamil Aug 24 '21 at 08:48
  • you may [edit](https://stackoverflow.com/posts/68884939/edit) your question with these findings – Gautham M Aug 24 '21 at 13:59

1 Answers1

0

You could use the ITestContext to set the test name.

@Test(dataProvider = "data")
public void testCase(ITestContext ctx, Sting testName, String testData1, String results){
    ctx.getCurrentXmlTest().setName(testName);  
    String s = doSomething(testData1);
    Assert.assertTrue(s, results);
}
Gautham M
  • 4,816
  • 3
  • 15
  • 37