1
votes

I just setup a new project (.net core: netcoreapp2.1) using xUnit Tests for UI test automation using selenium. I can run the tests via build and release pipelines on devops, but I cannot get the test results on the tests tab.

Now I'm wondering: how do I get XML-Reports of my testruns. On the release pipeline, I have a Publish Test Result task, but results are not getting published with the error below.

No Result Found to Publish 'D:\a\r1\a\Global Platform-QA\drop\TestResults\TEST.XML'. 2019-06-27T02:48:16.2148676Z No build level attachments to publish.

I have tried changing the test result format to junit but I am still missing something. I have added an empty TEST.XML to the testresults folder as well, but still haven't been able to figure out the missing link.

Below is the yaml for the build and release pipelines on devops. pool:steps: steps: - task: DotNetCoreCLI@2 displayName: Restore inputs: command: restore projects: '**/*.csproj'

    - task: DotNetCoreCLI@2
       displayName: Build
         inputs:
        projects: '**/*.csproj'
        arguments: '--configuration $(BuildConfiguration)'

    - task: DotNetCoreCLI@2
      displayName: Publish
      inputs:
      command: publish
      publishWebProjects: false
      projects: '$(Parameters.RestoreBuildProjects)'
      arguments: '--configuration $(BuildConfiguration) --output 
      $(build.artifactstagingdirectory)'
      zipAfterPublish: false
      modifyOutputPath: false

    - task: PublishBuildArtifacts@1
      displayName: 'Publish Artifact'
      inputs:
      PathtoPublish: '$(build.artifactstagingdirectory)'
      condition: succeededOrFailed()

Release pipeline:

    steps:
    - task: DotNetCoreCLI@2
      displayName: CVProSmokeTest
      inputs:
        command: custom
        projects: '**/CVProSmokeTest.dll'
        custom: vstest
        arguments: '--logger:trx;logfilename=TEST.xml'
        workingDirectory: '$(System.DefaultWorkingDirectory)'
      continueOnError: true
      condition: succeededOrFailed()
      timeoutInMinutes: 20

    steps:
    - task: PublishTestResults@2
      displayName: 'Publish Test Results'
      inputs:
        testResultsFormat: XUnit
        testResultsFiles: '**/TEST.xml'
        mergeTestResults: true
        testRunTitle: Selenium
      condition: succeededOrFailed()
      timeoutInMinutes: 20
1

1 Answers

1
votes

One of my colleagues helped me fix the pipeline, here are the modified steps, before and after the dotnet CLI task, bash script was added for files. pre build list files steps: - bash: | pwd

ls -alR workingDirectory: '$(System.DefaultWorkingDirectory)' displayName: ' Pre-Build List Files'

After the build task, before publish, post build list files. steps: - bash: | pwd

ls -alR

cat */test-results.xml workingDirectory: '$(System.DefaultWorkingDirectory)' displayName: ' Post-Build List Files'

The results are published and can be viewed under the Tests tab. https://developercommunity.visualstudio.com/content/problem/624719/publishing-xunit-test-results-to-azure-devops.html