test_badge_gen
**Test Badge Coverage ** is a simple command-line tool for generating test coverage badges in SVG format from an lcov.info file.
Features
- Generate test coverage badges based on
lcov.infofiles. - Customize the output file path for generated badges.
- Built with Dart for speed and reliability.
- Provides helpful console output and guidance.
Installation
- Active
test_badge_genpackage :- Flutter:
flutter pub global activate test_badge_gen- Or with Dart:
dart pub global activate test_badge_gen - Ensure that the CLI executable is globally available. Add the Dart bin folder to your PATH:
export PATH="$PATH":"$HOME/.pub-cache/bin" - Verify the installation:
badge-test --help
Usage
The badge-test CLI provides commands for generating test coverage badges. Below are usage instructions with examples.
Command: gen
The gen command generates a badge from the specified lcov.info file.
Syntax:
badge-test gen --in=<path_to_lcov.info> --out=<output_path>
Options:
| Option | Description | Required | Default |
|---|---|---|---|
| --in= | The input path to the lcov.info file. | Yes | None |
| --out= | The output path for the generated badge. If not specified, defaults to coverage_badge.svg. | No | coverage_badge.svg |
Example:
-
Basic Usage:
badge-test gen --in=lcov.infoThis generates a badge file named coverage_badge.svg in the current directory.
-
Custom Output Path:
badge-test gen --in=lcov.info --out=badges/test_coverage.svgThis generates a badge file at the specified output path.
-
Error Handling: If the input file is missing or invalid, the command will prompt an error message:
Generator failed! Please input lcov.info file path.
Additional information
To show in README
Add

Running the CLI Locally
Clone the repository:
git clone https://github.com/MinhMark123123/m_cli.git
cd m_cli/test_badge_gen
Activate the CLI locally:
dart pub global activate --source path .
Run :
badge-test gen --in=lcov.info
Running Tests 🧪
To run all unit tests:
dart pub global activate coverage
dart test --coverage=coverage
dart pub global run coverage:format_coverage --lcov --in=coverage --out=coverage/lcov.info
To view the generated coverage report you can use lcov.
# Generate Coverage Report
genhtml coverage/lcov.info -o coverage/
# Open Coverage Report
open coverage/index.html
To Generate badge image
badge-test gen --in=coverage/lcov.info