Can Ranorex connect to 'Test plans' of Azure Devops ??

Ask general questions here.
Rika L.
Posts: 18
Joined: Thu Nov 19, 2020 10:03 am

Can Ranorex connect to 'Test plans' of Azure Devops ??

Post by Rika L. » Fri Jul 16, 2021 6:57 pm

Hello everyone,
I have seen in this page: https://www.ranorex.com/help/latest/int ... -pipeline/, I have found Ranorex can connect with pipelines.
Can Ranorex connect with 'Test Plans'? I hope Ranorex can after testing the test results automatically send to Azure Devops. Is it possible?

Best regards
Rika

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Can Ranorex connect to 'Test plans' of Azure Devops ??

Post by odklizec » Mon Jul 19, 2021 7:35 am

Hi Rika,

If you want to attach a rxzlog to test runs summary, then I'm afraid, it's not an easy task and definitely not done automatically ;) You need to create a PowerShell script, which does what you want. I'm using something like this (you must have personal access token)...

Code: Select all

  - task: PowerShell@2
    displayName: Attach Ranorex report to test summary
    env:
      SYSTEM_ACCESSTOKEN: $(System.AccessToken)
    inputs:
      continueOnError: true
      targetType: 'inline'
      script: |
        #$AzureDevOpsPAT = "YourPersonalAccessToken"
        #$AzureDevOpsAuthenicationHeader = @{Authorization = 'Basic ' + [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($AzureDevOpsPAT)"))}
        $AzureDevOpsAuthenicationHeader = @{Authorization = "Bearer $env:SYSTEM_ACCESSTOKEN"}
        # Build Id
        Write-Host "buildID: $(Build.BuildId)"
        $url = 'https://PathToYourAzureProject/_apis/test/ResultDetailsByBuild?buildId=$(Build.BuildId)'
        $response = Invoke-RestMethod -Uri $url -Headers $AzureDevOpsAuthenicationHeader -Method Get
        Write-Host "response = $($response)"
        # get test run Id
        $testRunId = $($response.resultsForGroup.results[0].testRun.id)
        Write-host "test run number = $($testRunId)"
        # convert file to base64 string
        $base64string = [System.Convert]::ToBase64String([IO.File]::ReadAllBytes("$(System.DefaultWorkingDirectory)\Reports\$(rxzlogFile)"))
        Write-host "Converted string = $($base64string)"
        # create request body
        $BuildReqBody= @{stream=$base64string;fileName="$(rxzlogFile)";comment="Ranorex report";attachmentType="GeneralAttachment"}
        $BuildReqBodyJson = $BuildReqBody | ConvertTo-Json -Compress
        # attach report to test run
        $htmlReportFile = Invoke-RestMethod -Uri "https://PathToYourAzureProject/_apis/test/Runs/$testRunId/attachments?api-version=6.0-preview.1" -Method Post -ContentType 'application/json' -Body $BuildReqBodyJson -Headers $AzureDevOpsAuthenicationHeader
The result of above code should look like this:
TestRuns_Results.png
You do not have the required permissions to view the files attached to this post.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

albertohirota
Posts: 2
Joined: Sun Apr 02, 2023 7:06 pm

Re: Can Ranorex connect to 'Test plans' of Azure Devops ??

Post by albertohirota » Thu Mar 07, 2024 6:13 pm

Can we update the test passing/failing results to each test case inside a test plan in Azure?