Skip to content

Commit 6a4e75a

Browse files
authored
Update the documentation for the skip parameter in the test (#2102)
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.
1 parent ba64bbb commit 6a4e75a

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

pkgs/test/test/runner/engine_test.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,18 @@ void main() {
257257
expect(bodyRun, isTrue);
258258
});
259259

260+
test('runs tests in the group when they are skip: false', () async {
261+
var bodyRun = false;
262+
var engine = declareEngine(() {
263+
group('group', () {
264+
test('test', skip: false, () => bodyRun = true);
265+
}, skip: true);
266+
});
267+
268+
await engine.run();
269+
expect(bodyRun, isTrue);
270+
});
271+
260272
test('exposes a LiveTest that emits the correct states', () {
261273
var entries = declare(() {
262274
group('group', () {

pkgs/test/test/runner/runner_test.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,8 @@ $_usage''');
519519
import 'package:test/test.dart';
520520
521521
void main() {
522-
test("success", () {});
522+
test('success', () {});
523+
test('explicitly unskipped', skip: false, () {});
523524
}
524525
''').create();
525526
});
@@ -532,7 +533,7 @@ $_usage''');
532533

533534
test('runs all tests with --run-skipped', () async {
534535
var test = await runTest(['--run-skipped', 'test.dart']);
535-
expect(test.stdout, emitsThrough(contains('+1: All tests passed!')));
536+
expect(test.stdout, emitsThrough(contains('+2: All tests passed!')));
536537
await test.shouldExit(0);
537538
});
538539
});

pkgs/test_core/lib/src/scaffolding.dart

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,12 @@ Declarer get _declarer {
9090
///
9191
/// If [skip] is a String or `true`, the test is skipped. If it's a String, it
9292
/// should explain why the test is skipped; this reason will be printed instead
93-
/// of running the test.
93+
/// of running the test. If a call to [test] is nested within a [group], a
94+
/// non-null `skip` parameter for the `test` will take precedence over the skip
95+
/// parameter in the `group`. For instance, if a `group` is set to `skip: true`,
96+
/// but a `test` within it is configured as `skip: false`, the `test` will not
97+
/// be skipped. A suite level `@Skip()` annotation cannot be overridden with
98+
/// `skip` arguments to `test` or `group`.
9499
///
95100
/// If [tags] is passed, it declares user-defined tags that are applied to the
96101
/// test. These tags can be used to select or skip the test on the command line,

0 commit comments

Comments
 (0)