8 / 8 · Book 14 · Exercises · drill: interview Q&A← prev⊞ allGet the book →
1.12Newman in GitHub Actions
jobs:
api-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- run: npm install -g newman newman-reporter-htmlextra
- run: |
newman run tests/collection.json \
--environment tests/staging.json \
--reporters cli,junit,htmlextra \
--reporter-junit-export results.xml \
--reporter-htmlextra-export report.html
- uses: actions/upload-artifact@v4
if: always()
with:
name: api-test-report
path: |
results.xml
report.html
PRO TIP: Always use
if: always()on the artifact upload step. This ensures test reports are saved even when tests fail -- which is exactly when you need them most.
2.2 pytest + requests: Full Control
For production API test suites, pytest with the requests library provides the flexibility, maintainability, and power that Newman cannot match.