I would also like native integration with Xray.
I created a batch file to upload the Junit_Report.xml generated by Kataon. I had to use a batch file because I needed a delay before using curl to upload the results.
When KataonC.exe executes from TestOps, the Junit_Report.xml is not generated until the Test Set is complete and closed. That means I can’t run curl directly from Katalon or Katalon’s TestListener “afterTestSuite”. Instead I have to use the batch with a delay.
Uploading using Curl will add the test case if it doesn’t exist and add the Pass/Fail.
JUnit is not mult-part so description, attachments, etc are not included. This is barebones test and status.
NOTE: Test name is full path included:
Step 1
Use TestListener “AfterTestSuite” to trigger batch file.
TestListener sends location of results folder to batch file.
@AfterTestSuite
def AfterTestSuite(TestSuiteContext testSuiteContext) {
‘Upload Junit_Report.xml results to Jira to create tests and test results’String folder = RunConfiguration.getReportFolder() KeywordUtil.logInfo('Loading results in [' + folder + '] to Xray') def a = Runtime.getRuntime().exec('cmd /C XrayUpload.bat ' + folder)
}
Step 2 - XRayUpload.bat (located in root folder of Katalon project)
NOTE: The testExecKey is fixed. It is my regression suite so no need to change it dynamically.
testExecKey=QTAK-1008
Execute batch file to “wait” and execute “curl”
@echo off
cls::folder argument is first argument
::Execute batch from Katalon but wait xx seconds to give Katalon time to generate results.
::Execute from Katalon without waiting for cmd to complete.
@echo Begin delay > “%1\XrayUploadResults.txt”
ping 127.0.0.1 -n 60 > nul@echo Generate Bearer Token >> “%1\XrayUploadResults.txt”
::Generate Bearer token
for /f %%a in (‘curl -H “Content-Type: application/json” -X POST --data “{ ““client_id””: ““JiraClientId””,”“client_secret”“: ““JiraClientSecret”” }” https://xray.cloud.xpand-it.com/api/v1/authenticate’) do (
set “$token=%%a”
goto:next):next
::echo The token is : %$token%@echo Folder is %1 >> “%1\XrayUploadResults.txt”
@echo Start Upload >> “%1\XrayUploadResults.txt”
::Execute curl to upload Junit_Report.xml to Xray.
::Path to xml is the single parameter passed to the batch file.
curl -H “Content-Type: text/xml” -X POST -H “Authorization: Bearer %$token%” --data @“%1\Junit_Report.xml” https://xray.cloud.xpand-it.com/api/v2/import/execution/junit?testExecKey=QTAK-1008@echo End Upload >> “%1\XrayUploadResults.txt”
:: **** END ****