Quantcast

[testng-dev] Add new Custom attribute at runtime in testng-results.xml file

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[testng-dev] Add new Custom attribute at runtime in testng-results.xml file

Keshav Nangare
Hi,

I have to add attribute "isBasic" in the testng result at runtime. I referred some links from the stackoverflow and googlgroups but still it is not adding in result xml.

Following is the code snippet that I have tried:

public class NewTest {


@Test
 
public void f() {
 
System.out.println("Success..");
 
ITestResult result = Reporter.getCurrentTestResult();
   result
.setAttribute("isBasic", "true");
 
}
}



Expected Output:


<?xml version="1.0" encoding="UTF-8"?>
<testng-results skipped="0" failed="1" total="1" passed="0">
 
<reporter-output>
 
</reporter-output>
 
<suite name="Default suite" duration-ms="28254" started-at="2016-12-29T12:54:29Z" finished-at="2016-12-29T12:54:57Z">
   
<groups>
   
</groups>
   
<test name="Default test" duration-ms="28254" started-at="2016-12-29T12:54:29Z" finished-at="2016-12-29T12:54:57Z">
     
<class name="testngexample.NewTest" isBasic="true">
       
<test-method status="FAIL" signature="f()[pri:0, instance:testngexample.NewTest@1a04f701]" name="f" duration-ms="28220" started-at="2016-12-29T18:24:29Z" finished-at="2016-12-29T18:24:57Z">
         
<reporter-output>
         
</reporter-output>
       
</test-method> <!-- f -->
     
</class> <!-- testngexample.NewTest -->
   
</test> <!-- Default test -->
 
</suite> <!-- Default suite -->
</testng-results>



Please help me to fix this issue.

Thanks in advance!!!

--
You received this message because you are subscribed to the Google Groups "testng-dev" 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-dev.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[testng-dev] Re: Add new Custom attribute at runtime in testng-results.xml file

Julien Herr
https://groups.google.com/forum/#!forum/testng-users is a better place for the question.

BTW, according to the documentation: http://testng.org/doc/documentation-main.html#logging-xml-reports

generateTestResultAttributesA boolean indicating if an <attributes> tag should be generated for each <test-method> element, containing the test result attributes (See ITestResult.setAttribute() about setting test result attributes). Each attribute toString() representation will be written in a <attribute name="[attribute name]"> tag.false

I supposed it will work if you activate the property.

Le jeudi 29 décembre 2016 15:04:16 UTC+1, Keshav Nangare a écrit :
Hi,

I have to add attribute "isBasic" in the testng result at runtime. I referred some links from the stackoverflow and googlgroups but still it is not adding in result xml.

Following is the code snippet that I have tried:

public class NewTest {


@Test
 
public void f() {
 
System.out.println("Success..");
 
ITestResult result = Reporter.getCurrentTestResult();
   result
.setAttribute("isBasic", "true");
 
}
}



Expected Output:


<?xml version="1.0" encoding="UTF-8"?>
<testng-results skipped="0" failed="1" total="1" passed="0">
 
<reporter-output>
 
</reporter-output>
 
<suite name="Default suite" duration-ms="28254" started-at="2016-12-29T12:54:29Z" finished-at="2016-12-29T12:54:57Z">
   
<groups>
   
</groups>
   
<test name="Default test" duration-ms="28254" started-at="2016-12-29T12:54:29Z" finished-at="2016-12-29T12:54:57Z">
     
<class name="testngexample.NewTest" isBasic="true">
       
<test-method status="FAIL" signature="f()[pri:0, instance:testngexample.NewTest@1a04f701]" name="f" duration-ms="28220" started-at="2016-12-29T18:24:29Z" finished-at="2016-12-29T18:24:57Z">
         
<reporter-output>
         
</reporter-output>
       
</test-method> <!-- f -->
     
</class> <!-- testngexample.NewTest -->
   
</test> <!-- Default test -->
 
</suite> <!-- Default suite -->
</testng-results>



Please help me to fix this issue.

Thanks in advance!!!

--
You received this message because you are subscribed to the Google Groups "testng-dev" 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-dev.
For more options, visit https://groups.google.com/d/optout.
Loading...