Skip to content

Update the documentation for the skip parameter in the test #2102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Mar 13, 2024
12 changes: 12 additions & 0 deletions pkgs/test/test/runner/engine_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,18 @@ void main() {
expect(bodyRun, isTrue);
});

test('runs tests in the group when they are skip: false', () async {
var bodyRun = false;
var engine = declareEngine(() {
group('group', () {
test('test', skip: false, () => bodyRun = true);
}, skip: true);
});

await engine.run();
expect(bodyRun, isTrue);
});

test('exposes a LiveTest that emits the correct states', () {
var entries = declare(() {
group('group', () {
Expand Down
5 changes: 3 additions & 2 deletions pkgs/test/test/runner/runner_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,8 @@ $_usage''');
import 'package:test/test.dart';

void main() {
test("success", () {});
test('success', () {});
test('explicitly unskipped', skip: false, () {});
}
''').create();
});
Expand All @@ -532,7 +533,7 @@ $_usage''');

test('runs all tests with --run-skipped', () async {
var test = await runTest(['--run-skipped', 'test.dart']);
expect(test.stdout, emitsThrough(contains('+1: All tests passed!')));
expect(test.stdout, emitsThrough(contains('+2: All tests passed!')));
await test.shouldExit(0);
});
});
Expand Down
7 changes: 6 additions & 1 deletion pkgs/test_core/lib/src/scaffolding.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,12 @@ Declarer get _declarer {
///
/// If [skip] is a String or `true`, the test is skipped. If it's a String, it
/// should explain why the test is skipped; this reason will be printed instead
/// of running the test.
/// of running the test. If a call to [test] is nested within a [group], a
/// non-null `skip` parameter for the `test` will take precedence over the skip
/// parameter in the `group`. For instance, if a `group` is set to `skip: true`,
/// but a `test` within it is configured as `skip: false`, the `test` will not
/// be skipped. A suite level `@Skip()` annotation cannot be overridden with
/// `skip` arguments to `test` or `group`.
///
/// If [tags] is passed, it declares user-defined tags that are applied to the
/// test. These tags can be used to select or skip the test on the command line,
Expand Down