I have made some automated test (Testcafe) and put them together in one of my VS projects folder as shown here.
1.Script to run and take screenshots on failure:
script: testcafe chrome **/Tests/**/* -S -s takeOnFails=true --reporter spec,xunit:report.xml
displayName: Run tests and save screenshots
continueOnError: true
2.Script for publishing:
- task: PublishTestResults@2
displayName: Publish test results
continueOnError: true
inputs:
testResultsFiles: '**/report.xml'
searchFolder: $(System.DefaultWorkingDirectory)
testResultsFormat: 'JUnit'
publishRunAttachments: true
testRunTitle: "Task Results"
failTaskOnFailedTests: false
3.Script for copying files and build artifact:
- task: CopyFiles@2
inputs:
sourceFolder: '$(Build.SourcesDirectory)'
contents: '**/?(*.png)'
targetFolder: '$(Build.ArtifactStagingDirectory)'
- task: PublishBuildArtifacts@1
inputs:
pathToPublish: '$(Build.ArtifactStagingDirectory)'
artifactName: Saved failure screenshots
Is there any way to add screenshots as attachment on test run created at step 2 like this using Yaml?
Currently screenshots can be seen at artifact result from step 3 but I want them to be attached to test run.