0
0
Postmantesting~8 mins

Reporter options (CLI, HTML, JUnit) in Postman - Framework Patterns

Choose your learning style9 modes available
Framework Mode - Reporter options (CLI, HTML, JUnit)
Folder Structure for Postman Test Automation
postman-project/
├── collections/
│   └── api-tests.postman_collection.json
├── environments/
│   ├── dev.postman_environment.json
│   ├── staging.postman_environment.json
│   └── prod.postman_environment.json
├── reports/
│   ├── cli-report.txt
│   ├── html-report.html
│   └── junit-report.xml
├── scripts/
│   └── pre-request-scripts.js
├── newman-config.json
└── README.md
  
Test Framework Layers in Postman with Newman
  • Collections: JSON files defining API requests and tests.
  • Environments: JSON files holding variables for different setups (dev, staging, prod).
  • Scripts: JavaScript files for pre-request or test scripts to add logic.
  • Reports: Output files generated by Newman in different formats (CLI text, HTML, JUnit XML).
  • Configuration: JSON or JS files to define Newman run options like reporters, environment, iteration count.
Configuration Patterns for Reporter Options

Use a newman-config.json file or CLI flags to configure reporters:

{
  "collection": "collections/api-tests.postman_collection.json",
  "environment": "environments/dev.postman_environment.json",
  "reporters": ["cli", "html", "junit"],
  "reporter": {
    "html": { "export": "reports/html-report.html" },
    "junit": { "export": "reports/junit-report.xml" }
  }
}
  

Run Newman with this config to generate all reports at once:

newman run --config newman-config.json
  

Or use CLI flags directly:

newman run collections/api-tests.postman_collection.json \
  -e environments/dev.postman_environment.json \
  -r cli,html,junit \
  --reporter-html-export reports/html-report.html \
  --reporter-junit-export reports/junit-report.xml
  
Test Reporting and CI/CD Integration
  • CLI Reporter: Shows test results in terminal for quick feedback.
  • HTML Reporter: Generates a detailed, easy-to-read report with test summaries and failures.
  • JUnit Reporter: Produces XML reports compatible with CI tools like Jenkins, GitLab, or GitHub Actions.
  • CI/CD Integration: Use Newman commands in pipeline scripts to run tests and publish reports automatically.
  • Example: Jenkins can parse JUnit XML to show test results in its dashboard.
Best Practices for Reporter Options in Postman Framework
  1. Use Multiple Reporters: Combine CLI for quick checks, HTML for detailed review, and JUnit for CI integration.
  2. Organize Reports: Save reports in a dedicated folder with clear names and timestamps for traceability.
  3. Automate Reporting: Integrate Newman runs and report generation in CI pipelines for consistent feedback.
  4. Keep Config Separate: Use config files for reporter settings to avoid repeating CLI commands and ease maintenance.
  5. Validate Reports: Regularly check generated reports to ensure they capture all test results and errors correctly.
Self Check Question

Where in this folder structure would you add a new HTML reporter configuration file if you want to customize the report style separately?

Answer: In the reports/ folder, alongside other report files, or create a reports/config/ subfolder for reporter-specific config files.

Key Result
Use Newman with multiple reporters (CLI, HTML, JUnit) configured via JSON or CLI for clear, automated Postman test reporting.