testng-team / testng

TestNG testing framework
https://testng.org
Apache License 2.0
1.99k stars 1.02k forks source link

name should not be test-instance-name when ITest is implemented #56

Closed nullin closed 13 years ago

nullin commented 13 years ago

See the following testng-results.xml.

<?xml version="1.0" encoding="UTF-8"?> <testng-results skipped="0" failed="0" total="11" passed="11"> <reporter-output> </reporter-output> <suite name="Tests::Suite" duration-ms="5130" started-at="2011-06-30T21:27:46Z" finished-at="2011-06-30T21:27:51Z"> <test name="INST_NAME:Tests" duration-ms="5130" started-at="2011-06-30T21:27:46Z" finished-at="2011-06-30T21:27:51Z"> <class name="testng.instancename.MyITestFactoryTest"> <test-method status="PASS" signature="factoryTest1()" test-instance-name="FACTORY_VMFS" name="FACTORY_VMFS" duration-ms="1023" started-at="2011-06-30T21:27:48Z" finished-at="2011-06-30T21:27:49Z"> </test-method> <test-method status="PASS" signature="factoryTest2()" test-instance-name="FACTORY_VMFS" name="FACTORY_VMFS" duration-ms="0" started-at="2011-06-30T21:27:49Z" finished-at="2011-06-30T21:27:49Z"> </test-method> <test-method status="PASS" signature="factoryTest1()" test-instance-name="FACTORY_NFS" name="FACTORY_NFS" duration-ms="1023" started-at="2011-06-30T21:27:49Z" finished-at="2011-06-30T21:27:50Z"> </test-method> <test-method status="PASS" signature="factoryTest2()" test-instance-name="FACTORY_NFS" name="FACTORY_NFS" duration-ms="0" started-at="2011-06-30T21:27:50Z" finished-at="2011-06-30T21:27:50Z"> </test-method> </class> </test> </suite> </testng-results>

If a test class implements ITest, the test-method name and test-instance-name are both being set to the name specified by ITest.getTestName(). While test-instance-name is correct, name should be the name of the method being executed.

TestNG eclipse plugin correctly handles this and shows the names differently.

nullin commented 13 years ago

Class responsible for generating the above report is:

package testng.instancename;

import org.testng.ITest; import org.testng.annotations.DataProvider; import org.testng.annotations.Factory; import org.testng.annotations.Test;

public class MyITestFactoryTest implements ITest { @DataProvider(parallel = true) public Object[][] dp() { return new Object[][] { new Object[] { "VMFS" }, new Object[] { "NFS" }, }; }

String data = null;

@Factory(dataProvider = "dp") public MyITestFactoryTest(String str) { data = str; }

@Test public void factoryTest1() {}

@Test public void factoryTest2() {}

@Override public String getTestName() { return "FACTORY_" + data; }

}

cbeust commented 13 years ago

Fixed: https://github.com/cbeust/testng/commit/fc108089b838bbe648813b76d73bdc43a026f868