In my report the last Test name in excel sheet is getting appended in my results. Here is my code
public class Test_suite implements ITest {
private String testInstanceName="";
public String getTestName()
{
return testInstanceName;
}
private void setTestName(String anInstanceName)
{
this.testInstanceName = anInstanceName;
}
@DataProvider()
public Object[][] Unit() throws Exception
{
Object[][] testObjArray = Excel.getTableArray("./Test Data/Test.xlsx","Unit");
return (testObjArray);
}
@BeforeMethod(alwaysRun=true)
public void before(Method method,Object[] parameters)
{
String testCaseId="";
testCaseId = parameters[0].toString();
System.out.println(testCaseId);
setTestName(testCaseId);
}
@Test(dataProvider="Unit")
public void Test(){
}
And my report looks like this

This is because all tests that uses a dataProvider will be executed in parallel. The default thread count used is 10. And as you can see, these methods use the same insance of the class, in your case Test_suite.java
The insance variable testInstanceName is mutable and is overwriten by every dataprovider thread and the latest is used to set as the test name. You can achieve what you are intending to do by containing the set test name logic within your before method and not using an instance variable