Get started with pytest-jux in 10 minutes
Audience: Infrastructure Engineers, Integrators, Developers Prerequisites: Python 3.11+, pytest installed in your project Time: ~10 minutes
By the end of this tutorial, you will:
- Install pytest-jux in your project
- Generate cryptographic signing keys
- Configure pytest-jux for local storage
- Run tests and produce signed XML reports
- Inspect and verify your signed reports
pytest-jux is a pytest plugin that:
- Signs your JUnit XML test reports with cryptographic signatures
- Stores reports locally (or publishes to an API server)
- Provides CLI tools for key management and report inspection
This creates a chain-of-trust for your test results, ensuring they haven't been tampered with.
In your project's virtual environment:
# Using uv (recommended)
uv pip install pytest-jux
# Or using pip
pip install pytest-juxVerify installation:
pytest --version
# Should show pytest-jux in the list of installed pluginsGenerate a private key for signing your test reports:
# Generate RSA key (recommended for most use cases)
jux-keygen --output ~/.jux/signing_key.pem --type rsa --bits 2048
# Generate with self-signed certificate (optional)
jux-keygen --output ~/.jux/signing_key.pem --type rsa --bits 2048 --certOutput:
✓ Generated RSA private key (2048 bits)
✓ Key saved: /Users/you/.jux/signing_key.pem
✓ File permissions set to 0600 (read/write for owner only)
✓ Certificate saved: /Users/you/.jux/signing_key.crt
⚠ Self-signed certificate - NOT suitable for production use
Important: Keep your private key secure! It's like a password for your test reports.
Create a configuration file in your project:
jux-config init --path .jux.conf --template minimalEdit .jux.conf:
[jux]
# Enable pytest-jux plugin
enabled = true
# Enable report signing
sign = true
# Path to signing key
key_path = ~/.jux/signing_key.pem
# Storage mode: local (no API server needed)
storage_mode = localAlternatively, add to your pytest.ini:
[pytest]
# Your existing pytest config...
junit_family = xunit2
[jux]
enabled = true
sign = true
key_path = ~/.jux/signing_key.pem
storage_mode = localRun your existing pytest tests with JUnit XML output:
pytest --junit-xml=report.xmlWhat happens:
- pytest runs your tests as normal
- JUnit XML report is generated
- pytest-jux automatically signs the report
- Signed report is stored locally in
~/.local/share/jux/reports/(macOS/Linux) - Original
report.xmlcontains the signature
Expected output:
======================== test session starts =========================
collected 10 items
tests/test_example.py::test_one PASSED [ 10%]
tests/test_example.py::test_two PASSED [ 20%]
...
======================== 10 passed in 0.50s ==========================
generated xml file: /path/to/report.xml
pytest-jux: Report signed and stored (sha256:abc123...)
View report details:
jux-inspect report.xmlOutput:
JUnit XML Report Summary
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Test Results:
Tests: 10
Failures: 0
Errors: 0
Skipped: 0
Report Details:
Canonical Hash: sha256:abc123def456...
Signature: ✓ Present (XMLDSig)
Test Suites: 1
Verify the signature:
jux-verify report.xml --cert ~/.jux/signing_key.crtOutput:
✓ Signature is VALID
Algorithm: RSA-SHA256
Certificate: CN=pytest-jux
List all cached reports:
jux-cache listOutput:
Cached Reports (1 total):
sha256:abc123def456...
Timestamp: 2025-10-17T14:30:00Z
Hostname: dev-laptop
Username: developer
View cache statistics:
jux-cache statsOutput:
Cache Statistics:
Total Reports: 1
Queued Reports: 0
Total Size: 2.5 KB
Oldest Report: 2025-10-17 14:30:00
You now have:
- ✅ pytest-jux installed and configured
- ✅ Cryptographic signing keys generated
- ✅ Signed test reports from your test suite
- ✅ Local storage with cached reports
- ✅ Verification capability for report integrity
- Understanding pytest-jux - Why XML signatures matter
- Choosing Storage Modes - When to use local/api/both/cache
- Setting Up Signing Keys - Production key management
- Configure for CI/CD: See CI/CD Deployment Guide
- Multiple Environments: See Multi-Environment Configuration
- Troubleshooting: See Troubleshooting Guide
- API Publishing: When your Jux API Server is available, change
storage_mode = apiorstorage_mode = both - Offline Queue: Use
storage_mode = cachefor unreliable network connections - Certificate Management: Generate production certificates with proper CA signing
Problem: pytest-jux doesn't seem to do anything.
Solution: Check that enabled = true in your config file.
# Verify current configuration
jux-config dumpProblem: jux-verify reports invalid signature.
Solution: Ensure you're using the matching certificate:
# The certificate must match the private key used for signing
jux-verify report.xml --cert ~/.jux/signing_key.crtProblem: Cannot write to storage directory.
Solution: Check storage path permissions:
# View storage location
jux-config dump | grep storage_path
# Create directory if needed
mkdir -p ~/.local/share/jux/reports
chmod 700 ~/.local/share/jux- Documentation: docs/
- Issues: GitHub Issues
- Security: Security Policy
Next Tutorial: Setting Up Signing Keys - Production key management and certificate authorities