Azure DevOps test -xml not found after running the Cypress tests

放肆的年华 提交于 2021-02-11 15:23:45

问题


Added a Publish test results task in Azure DevOpsCI/CD pipeline, test were successfull, but after running the test it complaints about ##[warning]No test result files matching **/test-*.xml were found. Could someone please advise on how can we resolve similar problem ?

Publish Test Results task : configuration

Test result format= JUnit
Test results files= **/test-*.xml
Search folder = $(System.DefaultWorkingDirectory)
Test results title = Cypress Test Results

note: I have try adding the search folder path as follows: C:\agent_work\r5\a\drop\ui-tests\cypress

package.json to run the tests

 "scripts": {
    "test": "cypress run --record --key <key value here>"
  }

My directory path in server: C:\agent_work\r5\a\drop\ui-tests\cypress


回答1:


My friend, I was facing the same issue on Azure DevOps. In my case, the folder where the xml files were generated was reports on the root of the repo, that depends on how you got configured Junit on your cypress.json file

So In my case, the solution was changing this on azure-pipelines.yml

testResultsFiles: "results/*.xml"
searchFolder: $(System.DefaultWorkingDirectory)

So that's the entire setup of the testing pipeline

# Node.js
# Build a general Node.js project with npm.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/javascript

trigger:
- master

pool:
  vmImage: 'ubuntu-latest'

steps:
- task: NodeTool@0
  inputs:
    versionSpec: '12.x'
  displayName: 'Install Node.js'

- script: "npm i"
  displayName: "Install project dependencies"

- script: "npm run cy:verify"
  displayName: "Cypress Verify"

- script: "source cypress.env"  # comment this script to run tests against production
  displayName: "Using env variables to change url to test against development branch"

- script: "npm run cy:run-report"
  displayName: "Run Cypress Tests" 

- task: PublishBuildArtifacts@1
  displayName: "Publish Artifact: cypress-azure-devops screenshots"
  inputs:
    PathtoPublish: cypress/screenshots
    ArtifactName: "CypressAzureDevopsTestRunScreenshots"
  condition: failed()

- task: PublishTestResults@2
  displayName: "Publish Test Results"
  condition: succeededOrFailed()
  inputs:
    testResultsFormat: "JUnit"
    testResultsFiles: "results/*.xml"
    searchFolder: $(System.DefaultWorkingDirectory)
    mergeTestResults: true
    testRunTitle: 'Test Results'
    continueOnError: true

Saludos desde Argentina 🇦🇷



来源:https://stackoverflow.com/questions/55152379/azure-devops-test-xml-not-found-after-running-the-cypress-tests

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!