Re: [testng-users] Is it possible to display custom methods name in TestNG reports?

Showing 1-6 of 6 messages
Re: [testng-users] Is it possible to display custom methods name in TestNG reports? Cédric Beust ♔ 8/10/12 6:18 AM
Have your test class extend org.testng.ITest and override getTestName().

-- 
Cédric




On Fri, Aug 10, 2012 at 5:49 AM, Arun Panda <arun.k...@gmail.com> wrote:
I know this can be done for junit reports generated by testng by extending JUnitReportReporter and overriding getTestName method.
But can this be done for TestNG reports? I really want this feature so that testcases having dataprovider can be displayed with some custom name e.g
methodname_filename for testng reports

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/testng-users/-/lfiUoJB7FRAJ.
To post to this group, send email to testng...@googlegroups.com.
To unsubscribe from this group, send email to testng-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.


Re: Is it possible to display custom methods name in TestNG reports? Arun Panda 8/13/12 2:52 AM
Thanks!!

But this turns out to be much more difficult to implement than i thought.
It was more straight forward while using it with JunitReportReporter listner, were i was able to get current method under exceution quite easily



    @Override
    protected String getTestName(ITestResult result)
    {
       if(result.getParameters()!=null )
       {
            TestParameters params = (TestParameters) result.getParameters()[0];
            HashMap<String, String> map = params.getParameters();
            String filepath = null;
            if(map.containsKey("INPUT_FILE"))
            {
                filepath = map.get("INPUT_FILE");
                StringBuilder ret = new StringBuilder();
                ret.append(result.getMethod().getMethodName());
....


Now how do i get method name in this case (i.e extending each test case or the base test case with ITest class.)

 My second query is, I am using jenkins to display testng results where i provide "test-output\*.xml" as TestNG XML report pattern, so
if i succeed to change the method name will it be updated in testng result xml also?

Thanks,
Arun





On Fri, Aug 10, 2012 at 6:49 PM, Cédric Beust ♔-2 [via TestNG] <[hidden email]> wrote:
Have your test class extend org.testng.ITest and override getTestName().

-- 
Cédric




On Fri, Aug 10, 2012 at 5:49 AM, Arun Panda <[hidden email]> wrote:
I know this can be done for junit reports generated by testng by extending JUnitReportReporter and overriding getTestName method.
But can this be done for TestNG reports? I really want this feature so that testcases having dataprovider can be displayed with some custom name e.g
methodname_filename for testng reports


--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/testng-users/-/lfiUoJB7FRAJ.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].

For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.


--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].

For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.



If you reply to this email, your message will be added to the discussion below:
http://testng.1065351.n5.nabble.com/Is-it-possible-to-display-custom-methods-name-in-TestNG-reports-tp16315p16317.html
To unsubscribe from TestNG, click here.
NAML



View this message in context: Re: Is it possible to display custom methods name in TestNG reports?
Sent from the testng-users mailing list archive at Nabble.com.
Re: [testng-users] Is it possible to display custom methods name in TestNG reports? Krishnan 9/7/12 1:15 AM
No, this cannot be done with the DataProvider. You will have to resort to using Factory annotation.
Here's how you would do it :

Create a @Factory annotated method and have it create instances of your test classes. The testclass can conveniently implement ITest interface. It would be good if you had your test class such that it has just one method name, there by helping you achieve this.

If this is also not a viable option, then you may have to resort to writing your own implementation of IReporter 


Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"



On Wed, Aug 29, 2012 at 12:19 PM, Neeraja <neeraja.r...@gmail.com> wrote:


Hi,
I am also facing a similar issue.
I need to overwrite the testcase name when i use Dataprovider for passing test data. Currently all tests show the same name in the report. I tried implementing ITest but don't know how i can overwrite the getTestName() method so that i can get different testcase name for each of the dataset. Can some one give me sample code with end to end integration. 

 Is there  a way where i pass my own test case name in the dataprovider as an argument which will be shown in the report.(This way i will get different name for each dataset)

Thanks,
Neeraja.



On Friday, 10 August 2012 18:48:29 UTC+5:30, Cédric Beust ♔ wrote:
Have your test class extend org.testng.ITest and override getTestName().

-- 
Cédric




On Fri, Aug 10, 2012 at 5:49 AM, Arun Panda <arun.k...@gmail.com> wrote:
I know this can be done for junit reports generated by testng by extending JUnitReportReporter and overriding getTestName method.
But can this be done for TestNG reports? I really want this feature so that testcases having dataprovider can be displayed with some custom name e.g
methodname_filename for testng reports


--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/testng-users/-/lfiUoJB7FRAJ.
To post to this group, send email to testng...@googlegroups.com.
To unsubscribe from this group, send email to testng-users...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.


--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/testng-users/-/AxtxtDWf9o0J.
To post to this group, send email to testng...@googlegroups.com.
To unsubscribe from this group, send email to testng-users...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.

Re: [testng-users] Is it possible to display custom methods name in TestNG reports? KV 7/29/13 9:50 AM
Hi Krishnan,

Could you please provide a sample code that can help achieve this? I used Factory with dataprovider but it gets executed before the test methods so I am not able to get the test method names which would make the name unique.
This is the code I have so far,

public class NewTest implements ITest {

String dataname = null;

@DataProvider(name="BasicDataProvider")

    public Object[][] getTestData() {

        Object[][] data = new Object[][] {

                { new TestParameters("TestCase1", "Sample test 1")},

                { new TestParameters("TestCase2", "Sample test 2")},

                { new TestParameters("TestCase3", "Sample test 3")},

                { new TestParameters("TestCase4", "Sample test 4")},

                { new TestParameters("TestCase5", "Sample test 5") }

        };

        return data;

    }

public NewTest() {}

@Factory(dataProvider = "BasicDataProvider")

public NewTest(TestParameters testParams) {

String testCase = "";

String classname;


if (testParams != null) {

testCase = testParams.getTestName();

}

// dataname = String.format("%s(%s)", cake);


Class<?> enclosingClass = getClass().getEnclosingClass();

if (enclosingClass != null) {

classname = enclosingClass.getName();

} else {

classname = getClass().getName();

}

dataname = classname + " " + testCase;

// System.out.println(">>>>>>><<<<<<<<<<<<<<"+dataname);

System.out.println("factory");


}


@Test(dataProvider="BasicDataProvider")

    public void testSample1(TestParameters testParams){

System.out.println("The test is run");

        //test code here

    }


    @Test(dataProvider="BasicDataProvider")

    public void testSample2(TestParameters testParams){

        //test code here

    }



@Override

public String getTestName()

{

return dataname;

}

}


It now just gets testsample 1 to 5. It would be unique if it can get the test method name along with it which would make it unique.


Thanks

KV.

Re: [testng-users] Is it possible to display custom methods name in TestNG reports? Krishnan 7/31/13 3:39 AM
Karthik,

Can you please take a look at this post of mine and see if that helps get started ?



Thanks and Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"


From: KV <karthik.v...@gmail.com>
Reply-To: <testng...@googlegroups.com>
Date: Monday, 29 July 2013 10:20 PM
To: <testng...@googlegroups.com>
Subject: Re: [testng-users] Is it possible to display custom methods name in TestNG reports?
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users...@googlegroups.com.

To post to this group, send email to testng...@googlegroups.com.
Visit this group at http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Re: [testng-users] Is it possible to display custom methods name in TestNG reports? p...@groupon.com 10/16/13 2:37 PM
Thank you so much. Your answer helped me after 4 months :)