Integration Katalon studio with azure devops

Hello,

I am trying to integrate Katalon Studio with Azure DevOps and automatically upload test results. I have been able to generate the test results as JUnit XML, but I’m struggling to map the Azure DevOps Test Case ID with the test cases in my Katalon project.

When using the built-in integration in Katalon Studio, the Test Case ID is automatically mapped, but I would prefer to set the Test Case ID programmatically within the test script itself.

Here is what I have tried:

Used the @TestCaseId annotation, but I received the error that the annotation cannot be resolved.
Tried to manually send the results using the Azure DevOps REST API, but the results are not properly mapped to the correct Test Case IDs in Azure DevOps.
Has anyone successfully managed to map the Test Case ID programmatically in Katalon? Any suggestions on how to send the results with the correct mapping to Azure DevOps?

Thank you in advance!

Tags: #AzureDevOps, #KatalonStudio, #TestCaseId, #Integration

1 Like

Hope this could help

Hi @katalon.colombina,

Welcome to our community. Yeah, mapping Katalon test cases to Azure DevOps Test Case IDs can be tricky, especially if you’re not using Katalon’s built-in integration. Since that automatically maps the IDs, doing it manually takes a bit of extra work.

The suggestions that you can try are:

  1. Include the Test Case ID in the Test Case Name or Tags
    One simple approach is to embed the Azure Test Case ID in the test case name or use tags so you can reference it later.

For example:

String testCaseId = '12345' // This is the Azure DevOps Test Case ID
  1. Use a Global Variable for the Test Case ID
    You can store the Test Case ID in Katalon’s execution profile and call it in your test script:
import com.kms.katalon.core.configuration.RunConfiguration

String testCaseId = RunConfiguration.getExecutionProfile().getGlobalVariable("TestCaseId")

This keeps things flexible in case you need to change the IDs later.

  1. Send the Results Manually Using Azure DevOps REST API
    If you’re uploading results manually, you need to make sure your API request correctly links each test result to the Azure Test Case ID.

Example of creating a test run in Azure DevOps:

curl -u user:token \
  -X POST "https://dev.azure.com/{organization}/{project}/_apis/test/runs?api-version=6.0" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Automated Test Run",
    "automated": true
  }'

This gives you a runId that you’ll use in the next step.

Uploading test results:

curl -u user:token \
  -X POST "https://dev.azure.com/{organization}/{project}/_apis/test/runs/{runId}/results?api-version=6.0" \
  -H "Content-Type: application/json" \
  -d '[
    {
      "testCaseTitle": "Test Case 12345",
      "outcome": "Passed",
      "testCase": {
        "id": "12345"
      }
    }
  ]'

Just make sure the "id" matches the Test Case ID in Azure.

Hope that these can help you. Thank you