When you run bin/featuremap test_coverage
, the test coverage statistics of the latest commit on the main branch will be pulled from CodeCov and collected into a set of per-feature test coverage statistics. This feature level test coverage data is then captured in the .feature_map/test-coverage.yml
file.
This command requires the following CodeCov account settings to be configured within the .feature_map/config.yml
file:
code_cov:
service: github
owner: Acme-Org
repo: sample_app
See the CodeCov API docs for more information about the expected values for these configurations.
Command
bin/featuremap test_coverage [optional git SHA]
Test coverage statistics can be pulled for a specific commit (e.g. the latest commit on a feature branch) by including the full commit SHA as an argument at the end of this CLI command (e.g. bin/featuremap test_coverage ae80a927654997be4f48d3dbcd1320083cf22eea
). Before running this command please check the CodeCov dashboard for your application to ensure test coverage statistics have been reported for this commit.
Using SimpleCov
The test_coverage
command also supports coverage information specified in SimpleCov’s json
format.
bin/featuremap test_coverage --use-simplecov --simplecov-path $COVERAGE_FILE
Notes
- SimpleCov mode requires at least one path to be specified with
--simplecov-path
- SimpleCov and CodeCov modes cannot be used together
Input
Running the bin/featuremap test_coverage
requires an active CodeCov API access token to be specified in the CODECOV_API_TOKEN
environment variable of your shell session. This token is used to retrieve coverage statistics from the CodeCov account configured in the .feature_map/config.yml
file.
Generating a CodeCov API Token
Use the following steps to generate a new CodeCov API token:
- Log into your CodeCov account
- Click the “Settings” menu option in the profile dropdown menu in the top right corner of the screen
- Click the “Access” menu option from the left-hand navigation menu of the Settings page
- Click the “Generate Token” button in the “API Tokens” section of the page
- Enter a descriptive name for the token (e.g. FeatureMap CLI) and click the “Generate Token” button
- IMPORTANT: Copy the access token value presented on the screen and store it in a secure location (e.g. 1Password entry, BitWarden entry, etc)
OPTIONAL: Store the token as an environment variable in your shell’s environment:
ZSH
echo 'export CODECOV_API_TOKEN="YOUR_CODECOV_API_TOKEN"' >> ~/.zshrc
source ~/.zshrc
Bash
echo 'export CODECOV_API_TOKEN="YOUR_CODECOV_API_TOKEN"' >> ~/.bashrc
source ~/.bashrc
Output
This command results in the generation of .feature_map/test-coverage.yml
. More information regarding this artifact can be found at Artifacts - Test Coverage.