developer9969
developer9969

Reputation: 5236

cannot see postman test results azure devops

I have some postman collections and I would like to run them in azure devops, for whatever the reason my tests are not published.

What Am I missing? If I remove "reporters: junit i can see the result in the step. I was expecting a tab "test" next to summary

resources:
- repo: self
  clean: true
queue:
  name: Hosted VS2017
  demands: npm

steps:
- task: Npm@1
  displayName: 'npm install'
  inputs:
    verbose: false    
    customCommand: 'install newman -g'
 
- task: NewmanPostman@4
  displayName: 'Postman tests'
  inputs:
    collectionFileSource: 'my.postman_collection.json'
    environmentSourceType: none
    reporters: junit
    ignoreRedirect: false
    bail: false    
    sslInsecure: false
    htmlExtraDarkTheme: false
    htmlExtraLogs: false
    htmlExtraTestPaging: false

- task: PublishTestResults@2
  inputs:
    testResultsFormat: 'JUnit' # Options: JUnit, NUnit, VSTest, xUnit
    testResultsFiles: '**/*.xml'       

Upvotes: 0

Views: 1396

Answers (2)

Kevin Lu-MSFT
Kevin Lu-MSFT

Reputation: 35259

What Am I missing? If I remove "reporters: junit i can see the result in the step. I was expecting a tab "test" next to summary

Based on my test, I could reproduce your issue.

Here are the following points, you need to check:

  1. The XML file path in Publish Test Result task.

By default, the Junit xml file will be saved at newman folder. enter image description here

You could set the file path with the following path:

- task: PublishTestResults@2
  displayName: 'Publish Test Results **/*/*.xml'
  inputs:
    testResultsFiles: '**/*/*.xml'

You can also change the Junit file output path: reporterJUnitExport field in NewmanPostman task

Example:

- task: NewmanPostman@4
  displayName: 'Newman - Postman'
  inputs:
    collectionFileSource: '$(build.sourcesdirectory)'
    Contents: 'kevintest123.postman_collection.json'
    environmentSourceType: none
    ignoreRedirect: false
    bail: false
    sslInsecure: false
    reporters: junit
    htmlExtraDarkTheme: false
    htmlExtraLogs: false
    htmlExtraTestPaging: false
    reporterJUnitExport: '$(Build.sourcesdirectory)\Results\junitReport.xml'
  1. You need to make sure that the Json file contain the test. When you Export the files in Postman, you need to add the content in test tab:

enter image description here

Here is a doc about Add test in Postman.

Then you could publish the test result to the test tab successfully via Publish test Restlt task.

enter image description here

Or you will get the following issue and the test result Junit xml file doesn't contain the test result:

enter image description here

Update:

Cannot find "continue on error" anywhere.anyideas

Yaml Editor

- task: PublishTestResults@2
  displayName: 'Publish Test Results **/*/*.xml'
  inputs:
    testResultsFiles: '**/*/*.xml'
  continueOnError: true

Classic editor

enter image description here

Upvotes: 1

PDHide
PDHide

Reputation: 19949

Junit report is generated in the newman folder in the current directory. You change this location as:

--reporter-junit-export a.xml 
--reporter-junit-export folder/a.xml

this will generate report as a.xml or a.xml in the folder/directory you specified.

you have to publish that using publishtest result , if you are not using --reporter-junit-export , then make sure workingdirectory for all the steps are same.

else give full path as :

--reporter-junit-export c:/folder/a.xml

and

in step give the full path of report:

- task: PublishTestResults@2
  inputs:
    testResultsFormat: 'JUnit' # Options: JUnit, NUnit, VSTest, xUnit
    testResultsFiles: 'c:/folder/a.xml' 

Upvotes: 0

Related Questions