Skip to content

Commit

Permalink
Update the documentation for the skip parameter in the test (#2102)
Browse files Browse the repository at this point in the history
Document that a `skip: false` on a `test` can override a skipped group,
but not a skipped suite.

Add a unit test for the behavior between `group` and `test`.

Update an integration test to demonstrate that a suite level `@Skip()`
annotation cannot be overridden, it will always show as _one_ test
skipped for the entire suite.
  • Loading branch information
gmpassos authored Mar 13, 2024
1 parent ba64bbb commit 6a4e75a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
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

0 comments on commit 6a4e75a

Please sign in to comment.