Issue
We are going with XUnit to run Selenium Functional Tests. In Microsoft Azure Devops, we have a pipeline stage which runs our functional tests.
If the test fails, I want to take a screenshot using the Web Driver and attach it to the test results output.
I know it can be done with NUnit (using TestContext), but how can I achieve this using XUnit? Not sure if this is correct, but is there a way using REST APIs that I could somehow achieve this?
Solution
XUnit still doesn't support TestContext, check here: https://github.com/xunit/xunit/issues/2133
After taking the screenshots, you may consider using Attachments - Create Test Result Attachment API to attach the screenshot to a test result:
POST https://dev.azure.com/{organization}/{project}/_apis/test/Runs/{runId}/Results/{testCaseResultId}/attachments?api-version=6.0-preview.1
Answered By - Cece Dong - MSFT
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.