test_coverage 0.1.1 test_coverage: ^0.1.1 copied to clipboard
Runs tests in Dart VM and collects coverage data.
test_coverage #
A simple command-line tool to collect test coverage information from Dart VM tests.
Usage: #
pub global activate coverage # required dependency of test_coverage
pub global activate test_coverage
In the root of your Dart VM project:
test_coverage
# Or
pub global run test_coverage
Result is saved in coverage.lcov
.
How it works #
The tool performs following steps:
1. Generates test/.test_coverage.dart
file which is essentially a "test all" script. #
It is recommended to add this file to your .gitignore
.
Below is an example of test/.test_coverage.dart
:
// Auto-generated by test_coverage. Do not edit by hand.
// Consider adding this file to your .gitignore.
import 'some_test.dart' as some_test;
import 'nested/other_test.dart' as other_test;
import 'some_other_test.dart' as some_other_test;
void main() {
some_test.main();
other_test.main();
some_other_test.main();
}
2. Runs the tests #
Following command is used to run the tests:
dart --pause-isolates-on-exit --enable_asserts --enable-vm-service \
test/.test_coverage.dart
3. Collects and formats coverage information #
When test execution is completed the tool runs collect_coverage
and
format_coverage
commands from the coverage
package.