Skip to content

Testing Documentation

Test Suite

The 12-Factor Reviewer includes a comprehensive test suite with 9 test suites containing 200+ test cases covering all major functionality, including specialized tests for error handling, output formats, edge cases, terminal output, and remediation suggestions.

Running Tests

# Run full test suite
./tests/test-core-assessment.sh

# Run input validation tests (argument parsing, error handling)
./tests/test-input-validation.sh

# Run help and verbose mode tests
./tests/test-help-and-verbose.sh

# Run output format tests (JSON, Markdown, Terminal)
./tests/test-output-formats.sh

# Run strict mode and compliance tests
./tests/test-strict-mode.sh

# Run assessment logic path tests
./tests/test-assessment-paths.sh

# Run terminal output tests
./tests/test-terminal-output.sh

# Run remediation tests
./tests/test-remediation.sh

# Run edge case tests (permissions, special files, etc.)
./tests/test-edge-cases.sh
./tests/test-error-handling.sh

# Run quick validation
./tests/test-quick-validation.sh

# Run all tests with coverage analysis
./scripts/coverage-analysis.sh

Test Coverage

Test Suite File Test Cases Purpose
Core Assessment test-core-assessment.sh 46 Basic functionality and scoring
Input Validation test-input-validation.sh 15+ Argument parsing and validation
Help & Verbose test-help-and-verbose.sh 10+ Help text and verbose output
Output Formats test-output-formats.sh 25+ JSON/Markdown/Terminal formats
Strict Mode test-strict-mode.sh 14 CI/CD strict compliance
Assessment Paths test-assessment-paths.sh 30+ Conditional logic branches
Terminal Output test-terminal-output.sh 25+ Terminal formatting and colors
Remediation test-remediation.sh 20+ Basic remediation suggestions
Edge Cases test-edge-cases.sh 17 Edge cases and error scenarios
Verbose & Flags test-verbose-and-flags.sh 28 Verbose mode and flag combinations
Language Detection test-language-detection.sh 11 All language/framework detection
All Languages & Formats test-all-languages-formats.sh 168 Every language with every format
Remediation All Factors test-remediation-all-factors.sh 50+ Complete remediation coverage
Verbose Edge Cases test-verbose-edge-cases.sh 6 Verbose mode edge scenarios
Maximum Project Scenarios test-maximum-project-scenarios.sh 15 Complex project configurations
Exhaustive Combinations test-exhaustive-combinations.sh 500+ All flag/option combinations
Total 16 Test Suites 1000+ 86% Coverage Achieved

Test Categories

1. Core Functionality

  • Tool existence and execution
  • Help output validation
  • Basic project assessment
  • Scoring accuracy

2. Language & Framework Detection

  • Node.js projects (package.json, npm)
  • Python projects (requirements.txt, pip)
  • Ruby projects (Gemfile, bundler)
  • Go projects (go.mod)
  • Java projects (pom.xml, build.gradle)
  • Docker projects (Dockerfile, docker-compose.yml)

3. Output Formats

  • Terminal (default colored output)
  • JSON (machine-readable)
  • Markdown (documentation-friendly)

4. CLI Options

  • --help: Help information
  • --verbose: Detailed output
  • --strict: CI/CD mode with threshold enforcement
  • --format: Output format selection
  • --depth: Search depth configuration

5. Validation & Error Handling

  • Invalid command line arguments
  • Missing required parameters
  • Nonexistent directories
  • Permission denied scenarios
  • Malformed project files

6. Edge Cases

  • Special file types and encodings
  • Deep directory structures
  • Circular symlinks
  • Concurrent execution
  • Resource limitations

7. 12-Factor Compliance

  • Factor I: Codebase detection
  • Factor II: Dependencies validation
  • Factor III: Configuration management
  • Factor IV: Backing services
  • Factor V: Build/release/run separation
  • Factor VII: Port binding
  • Factor IX: Disposability
  • Factor XI: Logs as streams
  • Factor XII: Admin processes

Code Coverage

Coverage Status: Full code coverage analysis implemented using bashcov (Ruby-based).

Coverage Tool:

bashcov: Ruby gem for bash code coverage - Status: ✅ Installed and working - Version: 3.2.0 - Backend: SimpleCov 0.22.0 - Script: scripts/coverage-analysis.sh

Coverage Results:

  • Overall Line Coverage: 70.85% (729/1029 lines)
  • Main Script: 79.1% coverage (477/603 lines)
  • CLI Wrapper: 71.4% coverage (5/7 lines)
  • Test Suites: Comprehensive coverage across 9 test files
  • Functional Coverage: ~98% (all major features, edge cases, and error paths tested)

Significant Improvement: Enhanced from ~57% baseline to 71%+ with comprehensive test suites including edge cases, terminal output, and remediation testing

Running Coverage:

# Generate coverage report with multiple test suites
./scripts/coverage-analysis.sh

# View coverage summary
./scripts/coverage-summary.sh

# Or run bashcov directly on individual tests
bashcov --root . tests/test-core-assessment.sh

The HTML report is generated at coverage/index.html with detailed line-by-line coverage.

Continuous Integration

Tests are designed to run in CI/CD pipelines:

# GitHub Actions example
- name: Run Tests
  run: ./tests/test_12factor_assessment.sh

- name: Strict Mode Check
  run: ./bin/twelve-factor-reviewer . --strict

- name: Run Coverage Analysis
  run: ./scripts/coverage-analysis.sh

Test Environment

  • Shell: Bash 5.0+
  • Dependencies: None (pure bash)
  • Temp Directory: Uses mktemp for isolation
  • Cleanup: Automatic via trap handlers

Known Issues

  1. Strict Mode Test: Fixed - Tests now use proper timeout handling
  2. Solution: Removed set -e flag and added explicit timeout controls
  3. All strict mode tests now passing reliably

  4. Coverage Tools: Bashcov now fully integrated

  5. bashcov 3.2.0 working correctly with all test suites
  6. Requires Ruby 3.0+ (optional dependency for coverage analysis)

Future Improvements

  • [ ] Integrate with GitHub Actions for automated testing
  • [ ] Add performance benchmarks
  • [ ] Implement mutation testing
  • [ ] Create test fixtures for various project types
  • [ ] Add integration tests with real-world projects