Skip to main content

prefer-unique-test-names

added in: 1.11.0

Warns when the test name is not unique within the same test suite.

A test with a non-unique name will be skipped when running from the IDE. Same goes for tests with non-unique names inside a for loop.

Example

❌ Bad:

void main() {
test('some test', () {});
test('some test', () {}); // LINT

for (final item in [1, 2, 3])
test('broken test', () {}); // LINT
}

✅ Good:

void main() {
test('some test', () {});

group('some group', () {
test('some test', () {});
});

for (final item in [1, 2, 3])
test('good test $item', () {});
}