JoSSte
JoSSte

Reputation: 3372

Generating junit skipped report in newman

I have a load of testcases in Postman, split into several collections, so that they can be run independently using Jenkins.

Calling collection

In package.json

newman run \"collections/${npm_config_collection}.postman_collection.json\" \
  -e \"environments/TEST.postman_environment.json\" \
  --reporters junitfull,htmlextra \
  --reporter-junitfull-export "newman/${npm_config_collection}.xml" \
  --reporter-htmlextra-export "newman/${npm_config_collection}.html" \
  Authorization --insecure --env-var access_token=$TOKEN

Reporting Results

post {
  always {
    echo ' * * *  Zipping HTMLExtra results'
    script {
      sh script: " zip -j newman/\$(date +'%Y-%m-%d_%H-%M-%S')_htmlreports.zip newman/*.html"
    }
    echo ' * * *  Publishing results as Zip file(s)'
    archiveArtifacts artifacts: 'newman/*.zip', allowEmptyArchive: true

    echo ' * * *  Publishing JUnit results'
    junit testResults: 'newman/*.xml', skipPublishingChecks: true, allowEmptyResults: true
  }
}

Since some of them are long-running, I have some parameters to enable or disable these collections. Skipping them varies the number of tests run (see image below).
Newman Test Trend

I would like the number of total cases/assertions to stay the same. As I see it, newman has no feature to mark the whole collection as skipped. Essentially I "just" need a junit xml report with the same names/number of tests marked as skipped. Besides writing a script to find the last run with the report file for that and marking them as skipped (or making a PR to introduce the feature to newman), is there a way to create a junit xml file with the requisite number of skipped tests?

Upvotes: 1

Views: 150

Answers (0)

Related Questions