Skip to main content

test_gates 0.1.0 copy "test_gates: ^0.1.0" to clipboard
test_gates: ^0.1.0 copied to clipboard

Test gates for the Dart and Flutter code that must not be wrong: per-file 100% line and branch coverage, static checks and mutation testing.

example/README.md

test_gates example #

A package with one gate: lib/coupon.dart decides what a customer pays, so it is listed in test-gates.json.

dart pub get
dart run test_gates check       # the gate exists, has its test, and is a pure module
dart run test_gates test        # dart test with coverage: 100% lines and branches of the gate
dart run test_gates selfcheck   # with unexecuted code in it, the gate fails
dart run test_gates mutation    # every small change to the gate is noticed by a test
test_gates check: OK (1 gate(s), 0 candidate(s))

Things to try:

  • Remove the two expectations for 0 and 100 percent from test/coupon_test.dart. test still passes, at 100%: every line and block is executed by the other cases. mutation fails and names the changes that nothing notices any more (percent < 0 → percent <= 0, percent > 100 → percent >= 100).
  • Add import 'dart:io'; to lib/coupon.dart. check rejects it: a gate is a pure module.
  • Add a function to lib/coupon.dart without a test. test fails with the line that was not executed.

In a package of your own, test_gates is a development dependency from pub.dev (dart pub add --dev test_gates), not a path.

0
likes
0
points
1.37k
downloads

Publisher

unverified uploader

Weekly Downloads

Test gates for the Dart and Flutter code that must not be wrong: per-file 100% line and branch coverage, static checks and mutation testing.

Repository (GitHub)
View/report issues

Topics

#testing #coverage #lcov #mutation-testing #cli

License

unknown (license)

Dependencies

analyzer

More

Packages that depend on test_gates