avoid_focused_tests
v1.1.0 Warning Testing Rules
Warns when a test or group is focused with solo: true. A soloed test silences every sibling in the same file — they are not reported as skipped, they are never considered, and the run still exits zero.
solo is a debugging aid. The defect is committing it, and the diff looks like nothing.
void main() { // Every other test in this file now silently does not run. test('the one I am debugging', () { expect(parse(input), equals(expected)); }, solo: true);
test('handles an empty manifest', () { expect(parse(''), isEmpty); });}A group focus does the same thing at group scope:
void main() { group('upload', () { test('retries once', () {}); }, solo: true);
group('download', () { // Never runs. test('streams to disk', () {}); });}Narrow the run from the command line. It leaves no trace in the source, so it cannot be committed by accident:
void main() { test('the one I am debugging', () { expect(parse(input), equals(expected)); });
test('handles an empty manifest', () { expect(parse(''), isEmpty); });}dart test --name 'the one I am debugging'dart test test/upload_test.dartflutter test --plain-name 'the one I am debugging'Never reported
Section titled “Never reported”solo: false is the default written out, and suppresses nothing:
void main() { test('runs like any other', () {}, solo: false);}There is deliberately no option to permit a focus. Unlike a skip, it has no documented-and-therefore-tolerable form — a reason string would not make the other tests run.
See also: package:test | eslint-plugin-jest: no-focused-tests
Turning this rule off
Section titled “Turning this rule off”This rule is in the recommended preset, so it is on with
preset: recommended, preset: opinionated or preset: pedantic. Add it to
preset: core with avoid_focused_tests: true.
To turn it off:
rules: avoid_focused_tests: falseTo keep the rule on but skip certain paths, use per-rule exclude.
Related rules
Section titled “Related rules”avoid_skipped_tests— Detect tests, groups and libraries switched off in place.avoid_misused_test_matchers— Detect test matchers used with incompatible value types.format_test_name— Hold test descriptions to a house pattern.prefer_correct_test_file_name— Name test files so the runner actually runs them.