Repository navigation
Progressive Testing Strategy
Systematic approach to testing PDF redaction: start simple, expand incrementally
Don't jump directly to complex PDFs. Build confidence progressively:
- Simple, known-good PDFs (demo files)
- Structural validation (file integrity)
- Feature-specific testing (content streams, fonts)
- Real-world documents (complex forms)
- Stress testing (large corpus)
Problem with jumping to complex cases:
- Hard to debug when basics don't work
- Unclear if issue is fundamental or edge case
- Wastes time on wrong problem
Benefits of progressive approach:
- Validates fundamentals first
- Isolates issues to specific features
- Builds systematic understanding
- Catches regressions early
Goal: Prove redaction works at all
Test PDFs: Your demo files (known-good, text-rich)
- Simple PDFs with actual text content
- Controlled, minimal complexity
- Easy to validate results
Test Strategy:
- Redact known text (e.g., "CONFIDENTIAL")
- Verify with external tool (pdftotext)
- Validate file size decreases
- Check visual black box appears
Success Criteria:
-
pdftotext output.pdf | grep "REDACTED_TEXT"returns nothing - Output PDF is smaller than input
- Output PDF is valid (opens without errors)
Time: 5 minutes
Exit Criteria: Must pass before proceeding to Phase 1
Goal: Ensure redaction doesn't corrupt PDF structure
Test Categories:
- 6.1 File structure (68 PDFs)
- 6.7 Metadata (414 PDFs - sample 20)
Test Strategy:
- Redact arbitrary areas (may not contain text)
- Validate output PDF structure is intact
- Check headers, trailers, xref tables not corrupted
- Verify metadata preserved or safely modified
Success Criteria:
- 95% of PDFs process without errors
- Output PDFs are valid
- No structural corruption
Time: 30 minutes
Exit Criteria: High pass rate on structural tests
Goal: Validate content stream parsing and rebuilding
Test Categories:
- 6.2 Graphics (58 PDFs)
- Focus on 6.2.10 Content streams
Test Strategy:
- Test content stream parsing doesn't crash
- Validate rebuilt content streams render correctly
- Check for visual artifacts after redaction
- Verify text extraction still works for non-redacted text
Success Criteria:
- 90% of PDFs process successfully
- No visual corruption of non-redacted content
- Content streams parse and rebuild correctly
Time: 1 hour
Exit Criteria: Content stream handling is stable
Goal: Validate font handling during redaction
Test Categories:
- 6.3 Fonts (15 PDFs)
- All subcategories (General, CIDFonts, subsets, metrics)
Test Strategy:
- Verify font information is preserved
- Test that non-redacted text uses correct fonts
- Validate font embedding remains intact
- Check font metrics are correct
Success Criteria:
- 95% of PDFs process successfully
- No font corruption in output
- Non-redacted text renders in correct font/size
- No "tofu" (missing glyph boxes)
Time: 2 hours
Exit Criteria: Font handling is correct, no font-related bugs
Goal: Validate form field redaction
Test Categories:
- 6.9 Interactive Forms (4 PDFs)
Test Strategy:
- Test redacting form field text
- Verify other fields remain intact
- Check form structure not corrupted
- Test with real-world forms (Birth Certificate, etc.)
Success Criteria:
- 90% of form PDFs process successfully
- Form field text can be redacted
- Form structure preserved
- Real-world forms redact correctly
Time: 1 hour
Exit Criteria: Can reliably redact form documents
Goal: Handle transparency, annotations, and other edge cases
Test Categories:
- 6.4 Transparency (4 PDFs)
- 6.5 Annotations (2 PDFs)
- 6.6 Actions (3 PDFs)
Test Strategy:
- Test PDFs with transparency groups
- Distinguish annotations from content
- Ensure interactive features not corrupted
- Validate redaction boxes appear correctly
Success Criteria:
- 80% of edge case PDFs process successfully
- Transparency handled correctly
- Annotations preserved or safely removed
Time: 2 hours
Exit Criteria: Edge cases handled gracefully
Goal: Validate at scale, catch unexpected issues
Test Strategy:
- Test 500-1000 random PDFs from full corpus
- Look for crashes, hangs, memory leaks
- Validate performance is acceptable
- Test diverse PDF features simultaneously
Success Criteria:
- 85% of corpus processes successfully
- No crashes or data corruption
- Performance acceptable (<5 seconds per page average)
- Known failures are documented
Time: 4+ hours (can run overnight)
Exit Criteria: Ready for production use
Always use external tools to validate redaction:
pdftotext (poppler-utils):
pdftotext output.pdf - | grep "REDACTED_TEXT"
# Should return nothing if redaction workedpdfinfo (poppler-utils):
pdfinfo output.pdf
# Validate PDF metadata and structureveraPDF (validation):
verapdf output.pdf
# Check PDF/A complianceUse automated test suites:
- Unit tests (220+ tests)
- Integration tests (74+ tests)
- GUI simulation tests (8+ tests)
Use provided scripts for corpus testing:
-
test-category.sh- Test specific category -
validate-all-categories.sh- Test all categories
| Phase | Minimum Pass Rate | Ideal Pass Rate |
|---|---|---|
| Phase 0 | 100% | 100% |
| Phase 1 | 95% | 98% |
| Phase 2 | 90% | 95% |
| Phase 3 | 95% | 98% |
| Phase 4 | 90% | 95% |
| Phase 5 | 80% | 90% |
| Phase 6 | 85% | 90% |
A test passes if:
- ✅ Code doesn't crash or hang
- ✅ Output PDF is valid (opens without errors)
- ✅ Redacted text is removed (verified externally)
- ✅ Non-redacted content is intact
- ✅ File size decreases (content removed, not just hidden)
A test fails if:
- ❌ Code crashes or hangs
- ❌ Output PDF is corrupted
- ❌ Redacted text still extractable
- ❌ Non-redacted content is corrupted
- ❌ File size increases or stays same
Temptation: Jump to complex PDFs (Birth Certificate)
Problem: When it fails, you don't know if it's a fundamental issue or edge case
Solution: Complete each phase before moving to next
Temptation: Trust your own logging that says "redaction succeeded"
Problem: Code can lie, bugs can hide
Solution: Always verify with external tools (pdftotext)
Temptation: Only test PDFs with lots of text
Problem: Miss structural and edge case issues
Solution: Test across all categories, even those with minimal text
Temptation: Skip *fail*.pdf files entirely
Problem: Miss opportunities to test error handling
Solution: Test a few *fail*.pdf files to ensure graceful failure
After fixing bugs, re-run all previous phases:
- Fix identified issue
- Re-run failing phase
- Re-run all earlier phases (ensure no regression)
- Continue to next phase if all pass
Example:
- Phase 3 fails due to font bug
- Fix font bug
- Re-run Phase 3 → should pass now
- Re-run Phases 0-2 → ensure fix didn't break basics
- Proceed to Phase 4
Track performance metrics during testing:
Metrics to track:
- Time per page
- Memory usage
- File size reduction percentage
- Success rate per category
Acceptable performance:
- Simple PDF (1 page, 50 ops): <100ms
- Complex PDF (1 page, 500 ops): <500ms
- Form (10 pages): <5 seconds
- Large document (100 pages): <1 minute
Document findings as you test:
GitHub Issues: For bugs found
- Create issue immediately when test fails
- Include PDF that caused failure
- Include error logs and stack traces
GitHub Discussions: For patterns and insights
- "Phase 2 findings: content stream edge cases"
- "Font handling observations"
- Share test results and statistics
Wiki Updates: For learned knowledge
- Update this page with new insights
- Add new edge cases to relevant pages
- Document workarounds and solutions
- veraPDF Test Corpus - Understanding the test PDFs
- Testing Strategies - General testing approaches
- PDF Content Streams - What we're testing in Phase 2
- PDF Font Types and Encodings - What we're testing in Phase 3
- Poppler Utils: https://poppler.freedesktop.org/
- veraPDF: https://verapdf.org/
- PDF Association: https://pdfa.org/