Comprehensive automated test suite for the dev-environment project.
tests/
├── README.md # This file
├── test_runner.sh # Main test runner
├── unit/ # Unit tests
│ ├── test_functions.sh # Helper function tests
│ ├── test_syntax.sh # Syntax validation tests
│ └── test_package_parsing.sh # Package config parsing tests
├── integration/ # Integration tests
│ ├── test_update.sh # Update script tests
│ ├── test_verification.sh # Verification script tests
│ └── test_git_hook.sh # Git hook tests
└── fixtures/ # Test data
├── test_packages.conf # Sample package config
└── test_configs/ # Sample config files
└── test_zshrc # Sample zshrc
./tests/test_runner.sh./tests/test_runner.sh --unit./tests/test_runner.sh --integration./tests/test_runner.sh --verbosemake test # Syntax validation
cd tests && ./test_runner.sh # Full test suite-
test_functions.sh
- Helper function tests
- String operations
- File path resolution
- Critical script existence
- Directory structure validation
-
test_syntax.sh
- Syntax validation for all scripts
- Shebang validation
- Executable permissions
- Script integrity
-
test_package_parsing.sh
- Package configuration parsing
- Array existence and validity
- Package list verification
- Duplicate detection
-
test_update.sh
- Update script functionality
- Flag support (--dry-run, --auto, --help)
- Error handling
- Git repository checks
-
test_verification.sh
- Verification script functionality
- Flag support (--fix, --deep, --report)
- Issue tracking
- Error handling
-
test_git_hook.sh
- Git hook template validation
- Change detection (packages, scripts)
- Hook installation in install.sh/setup.sh
- Syntax and error handling
The test runner provides these assertion functions:
assert_equals expected actual test_nameassert_not_equals not_expected actual test_nameassert_true condition test_nameassert_file_exists file test_nameassert_command_exists command test_name
#!/bin/bash
# Get paths
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
echo "Running my new tests..."
echo ""
# Test 1: Example test
test_example() {
assert_equals "expected" "actual" "Test description"
}
# Run all tests
test_example
echo ""
echo "My new tests complete"#!/bin/bash
# Get paths
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
echo "Running integration tests..."
echo ""
# Test 1: Script exists
test_script_exists() {
assert_file_exists "$REPO_ROOT/script.sh" "script.sh exists"
}
# Run all tests
test_script_exists
echo ""
echo "Integration tests complete"- Naming: Test files must start with
test_and end with.sh - Executable: All test files must be executable (
chmod +x) - Isolated: Tests should not depend on each other
- Fast: Keep tests quick (< 1 second each when possible)
- Clear: Use descriptive test names
- Self-contained: Tests should clean up after themselves
Tests run automatically on:
- Every push to the repository
- Every pull request
- Manual workflow dispatch
See .github/workflows/test.yml for CI/CD configuration.
- Target: 80%+ test coverage
- Current: ~60 tests covering core functionality
- Status: Good coverage of critical paths
./tests/test_runner.sh --verbosebash tests/unit/test_functions.shbash -n tests/unit/test_functions.shTests are considered successful when:
- ✅ All tests pass
- ✅ Pass rate is 100%
- ✅ No syntax errors
- ✅ Exit code is 0
Last Updated: 2025-11-04 Test Suite Version: 1.0 Status: Active