This project demonstrates test coverage collection across multiple programming languages (TypeScript, Python, and C++), with support for both standardized LCOV format and native coverage reports.
.
├── ts/ # TypeScript implementation
├── python/ # Python implementation
├── cpp/ # C++ implementation
├── lcov-reports/ # Standardized LCOV format reports
├── coverage-reports/ # Native format coverage reports
└── mock-diffs/ # Mock diff files for testing
- Node.js and npm (for TypeScript)
- Python 3.x and pip (for Python)
- CMake and a C++ compiler (for C++)
- LCOV (for C++ coverage reports)
This project provides two different ways to generate coverage reports, each serving a different purpose:
Use generate_lcov_reports.sh to generate standardized LCOV format reports for parsing and analysis:
./generate_lcov_reports.shThis script:
- Runs tests for each language
- Generates coverage data in LCOV format
- Collects all reports in the
lcov-reports/directory:lcov-reports/typescript.lcovlcov-reports/python.lcovlcov-reports/cpp.lcov
These reports are standardized for:
- Automated parsing and analysis
- Cross-language coverage comparison
- Integration with CI/CD systems
- Use with LCOV-compatible tools
Use generate_coverage_reports.sh to generate detailed coverage reports in each language's native format:
./generate_coverage_reports.shThis script:
- Runs tests for each language
- Generates comprehensive coverage reports in native formats
- Creates HTML reports and summaries
- Saves all reports in
coverage-reports/<language>/:- TypeScript: Jest coverage reports
- Python: pytest-cov reports
- C++: gcov/lcov detailed reports
These reports are useful for:
- Detailed code coverage analysis
- Interactive HTML report viewing
- Language-specific coverage features
- Development and debugging
Each language can also generate reports independently:
cd ts
npm install
npm run test:report # Generates detailed Jest coverage reportscd python
./test_coverage.sh # Generates pytest-cov reportscd cpp
./test_coverage.sh # Generates detailed gcov/lcov reports- TypeScript: 100% (16/16 lines)
- Python: 100% coverage
- C++: 96.4% (27/28 lines)
- Add your test files in the respective language directories
- Update the corresponding test scripts if needed
- Run both coverage scripts to verify:
./generate_lcov_reports.shfor standardized LCOV reports./generate_coverage_reports.shfor detailed native reports
The mock-diffs/ directory contains sample diff files for testing LCOV parsing:
typescript.diffpython.diffcpp.diff
- The project maintains two types of coverage reports:
- Standardized LCOV format (
lcov-reports/) for automated processing - Native format reports (
coverage-reports/) for detailed analysis
- Standardized LCOV format (
- Each language uses its standard testing framework:
- TypeScript: Jest
- Python: pytest with pytest-cov
- C++: Google Test with gcov/lcov
- All LCOV format reports are normalized for consistent parsing
- Native reports provide additional language-specific insights
Each project contains identical test cases to verify the following coverage types:
-
Function Coverage
- Basic addition function
-
Branch Coverage
- Division function (including division by zero error handling)
-
Anonymous Function/Lambda Coverage
- Number processing function (with custom processor support)
-
Line and Complex Branch Coverage
- Grade calculation function (multiple conditional branches)
If you want to run tests for a specific project, follow these steps:
cd ts
npm install
npm testcd python
python3 -m venv venv
source venv/bin/activate # On Windows use: venv\Scripts\activate
pip install -r requirements.txt
pytest --cov=. --cov-report=lcov
deactivatecd cpp
mkdir -p build
cd build
cmake ..
make
./calculator_test
lcov --capture --directory . --output-file coverage.lcov- Ensure you have the necessary permissions to run
run_tests.sh(you may need to runchmod +x run_tests.sh) - Some systems may require additional development tools and compilers
- System-level dependencies might require
sudoprivileges to install
Each project implements a Calculator class with the following features:
-
Basic arithmetic operations
- Addition (function coverage example)
- Division (branch coverage example)
-
Advanced functionality
- Number processing with custom lambda functions
- Grade calculation with multiple branches
-
Comprehensive test coverage
- Unit tests for all functions
- Edge case handling
- Error condition testing
If you encounter any issues:
- Verify all required dependencies are installed
- Check system permissions
- Ensure all build tools are properly configured
- For Python virtual environment issues, try recreating the venv
Feel free to contribute to this project by:
- Adding support for more programming languages
- Enhancing test coverage
- Improving build scripts
- Updating documentation
This project is licensed under the MIT License - see the LICENSE file for details.