avoid-empty-test-groups

Path
lint/correctness/avoid-empty-test-groups
Default
Off, opt in
Origin
Falcon
Domain
test
Rule
61 of 512
test

Reports inline framework groups without any test registrations.

include-methods (array of strings, default: []) adds custom test registration helpers.

Invalid

example.dartdart
import 'package:test/test.dart';
void main() {
  group('empty', () {});
  group('setup only', () { setUp(() {}); });
  group('nested empty', () {
    group('also empty', () {});
  });
  group('statements', () { final value = 1; final other = value + 1; });
  group('lifecycle callback calls do not register tests', () { setUp(() { print('setup'); }); });
}
Add a test to this group or remove the empty group.
2void main() {
3 group('empty', () {});
Add a test to this group or remove the empty group.
3 group('empty', () {});
4 group('setup only', () { setUp(() {}); });
Add a test to this group or remove the empty group.
5 group('nested empty', () {
6 group('also empty', () {});
Add a test to this group or remove the empty group.
7 });
8 group('statements', () { final value = 1; final other = value + 1; });
Add a test to this group or remove the empty group.
8 group('statements', () { final value = 1; final other = value + 1; });
9 group('lifecycle callback calls do not register tests', () { setUp(() { print('setup'); }); });

Valid

example.dartdart
import 'package:flutter_test/flutter_test.dart' as t;
void callback() {}
void main() {
  t.group('one', () { t.test('works', () {}); });
  t.group('nested', () { t.group('inner', () { t.test('works', () {}); }); });
  t.group('widget', () { t.testWidgets('works', (tester) {}); });
  t.group('external callback', callback);
  t.group('skipped tests still registered', () { t.test('skipped', () {}, skip: true); });
  void group(String description, dynamic body) {}
  group('local function', () {});
}

Configure avoid-empty-test-groups

Set its severity in falcon.json. See the configuration guide.

falcon.jsonjson
{
  "linter": {
    "rules": {
      "correctness": {
        "avoid-empty-test-groups": "error"
      }
    }
  }
}

Or silence one occurrence with a suppression comment; the reason is required.

example.dartdart
// falcon-ignore lint/correctness/avoid-empty-test-groups: <reason>