Skip to main content

avoid-empty-test-groups

added in: 1.14.0
⚙️🛠
Pro+
preset: recommended

Warns when a test group does not have any test cases.

Empty test groups are either the result of unfinished refactoring or added by mistake.

⚙️ Config

Set include-methods (default is empty) to treat additional method invocations as test cases.

analysis_options.yaml
dart_code_metrics:
rules:
- avoid-empty-test-groups:
include-methods:
- customTest

Example

❌ Bad:

group('some group', () {
// LINT: This test group does not contain any test cases.
group('inner group', () {});
});

group('some group', () {
// LINT: This test group does not contain any test cases.
group('inner group', () {
setUp({
...
});
});
});

✅ Good:

group('some group', () {
group('inner group', () { // Correct, has a test case
test('...', {
...
});
});
});

group('some group', () {
group('inner group', () { // Correct, has a test case
setUp({
...
});

test('...', {
...
});
});
});

Additional Resources