Skip to content

Commit 62855be

Browse files
committed
Add tests
Add a unit test for the described behavior. Update an integration test to demonstrate that a suite level `@Skip()` annotation cannot be overridden, it will always show as _one_ test skipped. Remove all but the first `[]` link for each reference in the paragraph. Surround the other references with backticks for code blocks.
1 parent 55115a3 commit 62855be

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
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: false);
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 & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +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. If a [test] is nested within a [group], the
94-
/// [skip] parameter within the [test] will take precedence over the
95-
/// [skip] parameter in the [group]. For instance, if a [group] is set to
96-
/// `skip: true`, but a [test] within it is configured as `skip: false`, the
97-
/// [test] will not be skipped.
93+
/// of running the test. If a call to [test] is nested within a [group], a
94+
/// non-null `skip` parameter for the 1test1 will take precedence over the skip
95+
/// parameter in the 1group1. For instance, if a 1group1 is set to `skip: true`,
96+
/// but a 1test1 within it is configured as `skip: false`, the 1test1 will not
97+
/// be skipped. A suite level `Skip()` annotation cannot be overridden with
98+
/// `skip` arguments to `test` or `group`.
9899
///
99100
/// If [tags] is passed, it declares user-defined tags that are applied to the
100101
/// test. These tags can be used to select or skip the test on the command line,

0 commit comments

Comments
 (0)