Krishnan Mahadevan <krishnan.mahadevan1978@...> writes:
>
>
> You could try passing it via <at> Parameters and then have the <at> Test
method set the value for the test name in a data member of your test class which
can be returned back by the ITest interface method.
>
> Would that help?On Wednesday, July 25, 2012, testnguser wrote:Hello,
> Thanks a lot for the tip. :) It works if I set the testName.
> My bad, I did not notice the documentation. Is there a way I can receive the
testName from my suite.xml file?
> Thanks!
>
> On Tuesday, July 24, 2012 10:00:28 AM UTC-7, Krishnan wrote:
> Javadocs :
http://testng.org/javadoc/org/testng/ITestResult.html#getTestName%28%29
>
>
> Thanks & Regards
> Krishnan Mahadevan"All the desirable things in life are either illegal,
expensive, fattening or in love with someone else!"On Tue, Jul 24, 2012 at 10:28
PM, Krishnan Mahadevan <krishnan.mahadevan1978 <at>
gmail.com>
wrote:Harini,getTestName() returns the value that you configure your Testclass
> Thanks & RegardsKrishnan Mahadevan"All the desirable things in life are either
illegal, expensive, fattening or in love with someone else!"
> On Tue, Jul 24, 2012 at 10:15 PM, testnguser
<
techie...@gmail.com> wrote:
>
> I have a listener extending TestListenerAdapter. Functions such as getMethod
etc. work perfectly. But getTestName() shows null. My TestNGSuite.xml file
specifies <suite ....><test name="hellotest" ....>//listener classpublic void
onTestFailure(ITestResult result) { System.out.println("Test Name
:: "+result.getTestName()); }Am I specifying it wrong?Thanks!
>
Hi Krishnan,
i have tried the same but for the first set of data i am getting the name as
"defaultTestName" and second set of data i am getting testcase name from first
set of dataprovider data.
can you please share some code how you have done.
here is the sample code snippet how i did. I want the first parameter of the
dataprovider to be set as testcase name in the report.
public class AuditIntegrationTest implements ITest{
private String name;
public AuditIntegrationTest(String name) {
this.name = name;
}
@Test(groups = { "Smoke", "Positive","Regression","example"}, dataProvider =
"sampleProvider")
public void testSampleTestcase(String testCase,
String testDesc) throws Exception {
//ITestAnnotation.setTestName(testDesc);
this.name=testCase;
assertNotNull(testDesc);
}
@DataProvider(name = "sampleProvider")
public static Object[][] getSampleProvider() {
Object[][] retObjArr = new Object[][] {
{"Testcase1", "sample1"},
{"Testcase2", "sample2"},
{"Testcase3", "sample3"},
};
return (retObjArr);
}
@Override
public String getTestName() {
// TODO Auto-generated method stub
return name;
}
}
Thanks in advance,
Neeraja