How to provide screenshots of failed tests in Azure DevOps test results

2 Answers 859 Views
Azure DevOps Test Execution Test Results
Daniel
Top achievements
Rank 3
Iron
Iron
Iron
Daniel asked on 10 Jan 2023, 02:40 PM | edited on 10 Jan 2023, 02:41 PM

Hey guys,

we currently want to achieve that screenshots of failed tests/test steps will be provided in the test results in Azure DevOps pipeline. Is there possible way to achieve this?

Part of our yaml code if needed:

jobs:
      - job: Test
        displayName: Testing Application
        steps:
              - task: CmdLine@2
                inputs:
                  script: |
                    "C:\Program Files (x86)\Progress\Test Studio\Bin\ArtOfTest.Runner.exe" list="$(Build.Repository.LocalPath)\$(testList)" junit out=$(Common.TestResultsDirectory)	
                continueOnError: true
                condition: ne(variables.testList, '') 
              - task: PublishTestResults@2
                inputs:
                  testResultsFormat: 'JUnit'
                  testResultsFiles: '$(Common.TestResultsDirectory)\**.xml'
                  failTaskOnFailedTests: true
                  testRunTitle: 'Acceptance Test'
                  publishRunAttachments: true
                condition: ne(variables.testList, '')

Thanks and regards,

Daniel

2 Answers, 1 is accepted

Sort by
1
Elena
Telerik team
answered on 11 Jan 2023, 01:20 PM

Hi Daniel,

I guess that you are using an Azure pipeline configured in similar manner as listed in our online documentation. Then you could insert additional task to copy the results folder to the build artifacts - check the screenshot for reference. 

The screenshots for a failing test are listed under the Test Studio project root folder in the Results sub-folder - there is the *.aiiresult file and a folder with the failure details. In the general case you get the latest version of the test project from a remote repository for each pipeline run, so if you upload the Results folder, the screeenshots should be easily accessible. 

To be honest with you I haven't configured such pipeline so far, but in theory this should work for what you need to accomplish. Another task in the pipeline that could also be used for copying the images is the Copy Files task

Please, give these options a try and let me know if you need additional assistance about this configuration.

Thank you for your cooperation in advance.

Regards,
Elena
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Test Studio course! Check it out at https://learn.telerik.com/.
Louis
Top achievements
Rank 1
commented on 13 Jan 2023, 10:03 AM

Hello Elena, 
I work for the same company as Daniel (to be explicit I was asking him to questioning to you about this specific problem). 

Our requirement would be to connect the screenshot with the "attachment" tab in the test runs not only upload it via copy files etc. 

 

How would we achieve this? 

Best regards,

Louis Mehring

1
Elena
Telerik team
answered on 16 Jan 2023, 04:07 PM

Hello Louis,

Thank you for following up with additional details on what you need to accomplish. 

I explored the options of the Azure pipelines and found that you can use the REST API services of Azure DevOps for this specific requirement. There is an API that could be configured to upload attachments to the specific test run -  you can check the Microsoft docs for that API here. Part of this API call is the {runId} and this could be obtained with another API call as described here. These API calls are using a user's PAT for authentication.

From Test Studio perspective you only need to know where the result of a test/test list run is output and take this from that location. As I discussed - by default the results are stored in the Results sub-folder under the project root one. Optionally you can use an argument in the command to specify a folder by your choice - this is the out option of the ArtOfTest.Runner.exe.

The rest of the configuration is Azure DevOps specifics and I have to mention I am not an expert in these. However, I also found a StackOverflow thread covering the same scenario - you can review it as it describes the case in details. 

I hope that this information will help you sort out how to extend the pipeline to accomplish all that you need. 

Regards,
Elena
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Test Studio course! Check it out at https://learn.telerik.com/.
Tags
Azure DevOps Test Execution Test Results
Asked by
Daniel
Top achievements
Rank 3
Iron
Iron
Iron
Answers by
Elena
Telerik team
Share this question
or