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