Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Failure to import testng-results.xml with 415 status code when accessing through API.

Neha Chaudhary July 16, 2019

I am trying to import the test execution results from a testng-results.xml file using the API endpoint POST /rest/raven/1.0/import/execution/testng but i am getting a 415 error code. is the results xml required to be in a particular format for XRay to be able to read or do i need to add some capabilities within my testing framework that might allow Xray to read the report without any issues ? 

 

Furthermore , how do i ensure that xray updates the test status to the correct test key within the execution ?

 

Any help to resolve this is welcome! 

1 answer

0 votes
Krishnanand Nayak
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 16, 2019

are you setting the request-header for content correctly? here is how you need to set it 

 

Content-Type: application/json
Neha Chaudhary July 16, 2019

any reason why content type would be application json when im trying to send xml file ? here is the code im using to import the results : 

 

String url = "https://myprojectserver/rest/raven/1.0/import/execution/testng?testExecKey=xxxxxxxxx";
File file = new File("./test-output/testng-results.xml");
PostMethod post = new PostMethod(url);

RequestEntity entity = new FileRequestEntity(file, "application/xml; charset=UTF-8");
post.setRequestEntity(entity);

HttpClient httpclient = new HttpClient();

try {
int status = httpclient.executeMethod(post);
System.out.println("Status of execution is : "+status);

System.out.println("Response body: ");
System.out.println(post.getResponseBodyAsString());

}
catch(Exception e) {
e.printStackTrace();
}
finally {
post.releaseConnection();
}
}

Krishnanand Nayak
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 16, 2019
Neha Chaudhary July 18, 2019

this is the test method i am trying to update in XRay.  I would like to update test key COOFSNAPN-439 present in an execution key COOFSNAPN-793. 

try{
LoginCMSComponents.loginCMS("opsmanager");
ReferralComponents.create_referrral(JSONparser.LoadJSON(TestSuiteRunner.data.get("Referral_Mandatory_Fields")));
ReportManager.step.log(Status.INFO,"Referral Created Successfully");
ITestResult result = Reporter.getCurrentTestResult();
result.setAttribute("test", "COOFSNAPN-439");

}
catch (Exception e) {
//exception handling
}

This is the testng-results file that is being generated  using the default reporting mechanism of testNG. For readability purposes however we are using extent reports which has been implemented in separate classes. - ReportManager

<?xml version="1.0" encoding="UTF-8"?>
<testng-results skipped="0" failed="0" total="1" passed="1">
<reporter-output>
</reporter-output>
<suite name="CMS Automation" duration-ms="89328" started-at="2019-07-16T09:48:56Z" finished-at="2019-07-16T09:50:25Z">
<groups>
<group name="Sanity">
<method signature="ReferralTest.TC_COOFSNAPN_439_Create_Referral_Manodatory_Fields()[pri:0, instance:test_repository.referral.ReferralTest@7c16905e]" name="TC_COOFSNAPN_439_Create_Referral_Manodatory_Fields" class="test_repository.referral.ReferralTest"/>
</group> <!-- Sanity -->
<group name="Regression">
<method signature="ReferralTest.TC_COOFSNAPN_439_Create_Referral_Manodatory_Fields()[pri:0, instance:test_repository.referral.ReferralTest@7c16905e]" name="TC_COOFSNAPN_439_Create_Referral_Manodatory_Fields" class="test_repository.referral.ReferralTest"/>
</group> <!-- Regression -->
</groups>
<test name="CMS Automation" duration-ms="89328" started-at="2019-07-16T09:48:56Z" finished-at="2019-07-16T09:50:25Z">
<class name="test_repository.referral.ReferralTest">
<test-method status="PASS" signature="initialiseTest()[pri:0, instance:test_repository.referral.ReferralTest@7c16905e]" name="initialiseTest" is-config="true" duration-ms="1903" started-at="2019-07-16T15:18:54Z" finished-at="2019-07-16T15:18:56Z">
<reporter-output>
</reporter-output>
</test-method> <!-- initialiseTest -->
<test-method status="PASS" signature="InitialiseDriver(java.lang.reflect.Method)[pri:0, instance:test_repository.referral.ReferralTest@7c16905e]" name="InitialiseDriver" is-config="true" duration-ms="16709" started-at="2019-07-16T15:18:56Z" finished-at="2019-07-16T15:19:12Z">
<params>
<param index="0">
<value>
<![CDATA[public static void test_repository.referral.ReferralTest.TC_COOFSNAPN_439_Create_Referral_Manodatory_Fields()]]>
</value>
</param>
</params>
<reporter-output>
</reporter-output>
</test-method> <!-- InitialiseDriver -->
<test-method status="PASS" signature="TC_COOFSNAPN_439_Create_Referral_Manodatory_Fields()[pri:0, instance:test_repository.referral.ReferralTest@7c16905e]" name="TC_COOFSNAPN_439_Create_Referral_Manodatory_Fields" duration-ms="69936" started-at="2019-07-16T15:19:12Z" finished-at="2019-07-16T15:20:22Z">
<reporter-output>
</reporter-output>
</test-method> <!-- TC_COOFSNAPN_439_Create_Referral_Manodatory_Fields -->
<test-method status="PASS" signature="closeBrowser(java.lang.reflect.Method)[pri:0, instance:test_repository.referral.ReferralTest@7c16905e]" name="closeBrowser" is-config="true" duration-ms="2640" started-at="2019-07-16T15:20:22Z" finished-at="2019-07-16T15:20:25Z">
<params>
<param index="0">
<value>
<![CDATA[public static void test_repository.referral.ReferralTest.TC_COOFSNAPN_439_Create_Referral_Manodatory_Fields()]]>
</value>
</param>
</params>
<reporter-output>
</reporter-output>
</test-method> <!-- closeBrowser -->
<test-method status="PASS" signature="Clean()[pri:0, instance:test_repository.referral.ReferralTest@7c16905e]" name="Clean" is-config="true" duration-ms="0" started-at="2019-07-16T15:20:31Z" finished-at="2019-07-16T15:20:31Z">
<reporter-output>
</reporter-output>
</test-method> <!-- Clean -->
</class> <!-- test_repository.referral.ReferralTest -->
</test> <!-- CMS Automation -->
</suite> <!-- CMS Automation -->
</testng-results>

 I am not quite sure how do i go about updating this execution result in JIRA. Any help would be greatly appreciated. 

 

Thanks! 

Krishnanand Nayak
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 19, 2019

At this point i would recommend reaching out to Xray @Xpand IT Support Team . Here is our format and works without any issue

<?xml version="1.0" encoding="UTF-8"?>
<testng-results skipped="1" failed="0" ignored="0" total="1" passed="0">
<reporter-output>
</reporter-output>
<suite name="Smoke_SUT" duration-ms="7044607" started-at="2019-05-03T15:36:47Z" finished-at="2019-05-03T17:34:11Z">
<groups>
</groups>
<test name="Create JP" duration-ms="17015" started-at="2019-05-03T15:36:47Z" finished-at="2019-05-03T15:37:04Z">
<class name="com.test.automation.foundation.CsvTestExecutor">
<test-method status="SKIP" signature="test(org.testng.ITestContext, com.test.automation.foundation.CsvRecord, java.lang.String)[pri:0, instance:com.test.automation.foundation.CsvTestExecutor@22d9bc14]" name="Smoke_SUT.Create" duration-ms="0" started-at="2019-05-03T15:37:04Z" data-provider="dataProvider" finished-at="2019-05-03T15:37:04Z">
<exception class="org.testng.SkipException">
<message>
<![CDATA[Http_1.1 Service Unavailable]]>
</message>
<full-stacktrace>
<![CDATA[org.testng.SkipException: Http_1.1 Service Unavailable
at com.test.automation.foundation.CsvTestExecutor.setServerUrl(CsvTestExecutor.java:625)
at com.test.automation.foundation.CsvTestExecutor.beforeMethod(CsvTestExecutor.java:379)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124)
at org.testng.internal.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:59)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:458)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:222)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:523)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:719)
at org.testng.internal.TestMethodWithDataProviderMethodWorker.call(TestMethodWithDataProviderMethodWorker.java:71)
at org.testng.internal.TestMethodWithDataProviderMethodWorker.call(TestMethodWithDataProviderMethodWorker.java:14)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
]]>
</full-stacktrace>
</exception> <!-- org.testng.SkipException -->
<reporter-output>
</reporter-output>
</test-method> <!-- Smoke_SUT.Create JP -->
</class> <!-- com.test.automation.foundation.CsvTestExecutor -->
</test> <!-- Create JP -->
</suite> <!-- Smoke_SUT -->
</testng-results>
Neha Chaudhary July 19, 2019

Thanks. I will reach out to them as well. Though it still isnt evident to me from your xml how this updates the appropriate test issue within the execution . Or is this creating generic tests once the results are uploaded to the execution?

May i have a look at the annotation and listener files you may have created ? (in case your project has implemented it ) 

My issue is also with the mapping of automation tests in framework to the test issues in JIRA . How do i ensure the mapping of my @techoneway method to the corresponding jira issue so that the correct test issue is updated with the corresponding pass fail status ? 

Neha Chaudhary July 19, 2019

@Xpand IT Support Team  perhaps you could help me out here ? Im guessing there is some gap in understanding and would be grateful for your help in resolving it. 

Suggest an answer

Log in or Sign up to answer