0

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

soccerway
  • 10,371
  • 19
  • 67
  • 132
  • 1
    Are you sure, if you are using `junit` reporter option, as mentioned here `cypress run --reporter junit --reporter-options "mochaFile=results/my-test-output.xml,toConsole=true"` . Reference: https://docs.cypress.io/guides/tooling/reporters.html#Reporter-Options – Kondasamy Jayaraman Mar 14 '19 at 02:29
  • I am using Azure DevOps ( VSTS) and if I choose Junit 'Command line' task option will it work ? Sorry i am very new to Azure DevOps and finding really hard to set it up.. My tests are passing now, but I am struggling withe the last bit of setting up the test results in Azure DevOps – soccerway Mar 14 '19 at 02:52
  • I don't think this will work, please try running the command I suggestion in a `Command line/ Shell` action. – Kondasamy Jayaraman Mar 14 '19 at 03:21
  • Will try that way – soccerway Mar 14 '19 at 03:22

1 Answers1

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://learn.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

Juampi Caceres
  • 316
  • 3
  • 4