retrieve name and value of parameters in TESTNG

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

retrieve name and value of parameters in TESTNG

Rahul Nair


Hi All,

Request  help on the below situation 

TestNGXML
---------
<test name="TestName" preserve-order="true">
        <parameter name="param1-name" value="param1-value"></parameter>
        <parameter name="param2-name" value="param2-value"></parameter>
        <classes>
            <class name="testClassName.testMethodName"/>
        </classes>
   </test>
   
  
A listener is used to verify the success and failures of the test class methods. Based on that the results are sent over an API to TestRail to mark the test case updated.
  
I want to retrieve both the parameter name and value from the ITestResult class.
ITestResult.getparameter() will return an object array of the values of the parameter.
I would like to know if there is a way to retrieve the name value of the parameters?

Please let me know if there are any questions.

Thanks,
Rahul

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: retrieve name and value of parameters in TESTNG

Krishnan Mahadevan

Have you tried ITestResult.getITestContext().getCurrentXmlTest().getLocalParameters() ?

This should give you a Map of all the parameters that are defined at the <test> tag level.

 

Thanks & Regards

Krishnan Mahadevan

 

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

My Scribblings @ http://wakened-cognition.blogspot.com/

My Technical Scribbings @ http://rationaleemotions.wordpress.com/


Reply-To: <[hidden email]>
Date: Wednesday, March 14, 2018 at 2:52 AM
To: testng-users <[hidden email]>
Subject: [testng-users] retrieve name and value of parameters in TESTNG

 

 

Hi All,

 

Request  help on the below situation 

 

TestNGXML

---------                                                                                                 

<test name="TestName" preserve-order="true">                                                                             

        <parameter name="param1-name" value="param1-value"></parameter>

        <parameter name="param2-name" value="param2-value"></parameter>

        <classes>

            <class name="testClassName.testMethodName"/>

        </classes>

   </test>

   

  

A listener is used to verify the success and failures of the test class methods. Based on that the results are sent over an API to TestRail to mark the test case updated.

  

I want to retrieve both the parameter name and value from the ITestResult class.

ITestResult.getparameter() will return an object array of the values of the parameter.

I would like to know if there is a way to retrieve the name value of the parameters?

 

Please let me know if there are any questions.

 

Thanks,

Rahul

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
[hidden email].
To post to this group, send email to
[hidden email].
Visit this group at
https://groups.google.com/group/testng-users.
For more options, visit
https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: retrieve name and value of parameters in TESTNG

Anda Spa
How can access the value of parameter of a test case added dynamically?

I added this parameter in     @Override
    public void alter(List<XmlSuite> suites) {
        XmlSuite suite = suites.get(0);
        List<XmlTest> tests = suite.getTests();

        System.out.println("size: " + tests.size());

        for (XmlTest t : tests) {

            sessionId = bt.getSessionIdBS();
            t.addParameter("sessionId", sessionId);
            System.out.println(sessionId);
        }

//        XmlTest anotherTest = new XmlTest(suite);
//        anotherTest.setName("foo");
//        anotherTest.setClasses(test.getClasses());
    }

but this is not accessible in my default report.

Thanks

miercuri, 14 martie 2018, 05:02:13 UTC+2, Krishnan Mahadevan a scris:

Have you tried ITestResult.getITestContext().getCurrentXmlTest().getLocalParameters() ?

This should give you a Map of all the parameters that are defined at the <test> tag level.

 

Thanks & Regards

Krishnan Mahadevan

 

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

My Scribblings @ <a href="http://wakened-cognition.blogspot.com/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwakened-cognition.blogspot.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHzOdYJCASIDF_28vQtkp9gnKAYSQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwakened-cognition.blogspot.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHzOdYJCASIDF_28vQtkp9gnKAYSQ&#39;;return true;">http://wakened-cognition.blogspot.com/

My Technical Scribbings @ <a href="http://rationaleemotions.wordpress.com/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frationaleemotions.wordpress.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEcBOKyRn0lpL8LDbBuyAlKdwgXwQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frationaleemotions.wordpress.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEcBOKyRn0lpL8LDbBuyAlKdwgXwQ&#39;;return true;">http://rationaleemotions.wordpress.com/


Reply-To: <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="7yQb_Gi7BwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">testng...@...>
Date: Wednesday, March 14, 2018 at 2:52 AM
To: testng-users <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="7yQb_Gi7BwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">testng...@...>
Subject: [testng-users] retrieve name and value of parameters in TESTNG

 

 

Hi All,

 

Request  help on the below situation 

 

TestNGXML

---------                                                                                                 

<test name="TestName" preserve-order="true">                                                                             

        <parameter name="param1-name" value="param1-value"></parameter>

        <parameter name="param2-name" value="param2-value"></parameter>

        <classes>

            <class name="testClassName.testMethodName"/>

        </classes>

   </test>

   

  

A listener is used to verify the success and failures of the test class methods. Based on that the results are sent over an API to TestRail to mark the test case updated.

  

I want to retrieve both the parameter name and value from the ITestResult class.

ITestResult.getparameter() will return an object array of the values of the parameter.

I would like to know if there is a way to retrieve the name value of the parameters?

 

Please let me know if there are any questions.

 

Thanks,

Rahul

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
<a href="javascript:" target="_blank" gdf-obfuscated-mailto="7yQb_Gi7BwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">testng-users+unsubscribe@googlegroups.com.
To post to this group, send email to
<a href="javascript:" target="_blank" gdf-obfuscated-mailto="7yQb_Gi7BwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">testng-users@....
Visit this group at
<a href="https://groups.google.com/group/testng-users" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/group/testng-users&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/group/testng-users&#39;;return true;">https://groups.google.com/group/testng-users.
For more options, visit
<a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.