Skip to main content

avoid-duplicate-test-assertions

added in: 1.12.0
🛠
preset: recommended

Warns when a test case has multiple test assertions with the same expression and expected value.

Example

❌ Bad:

void withEmpty() {
final array = [1, 2, 3];

expect(array, isEmpty);
expect(array, isEmpty); // LINT
}

✅ Good:

void withEmpty() {
final array = [1, 2, 3];

expect(array, isEmpty);
expect(array, contains(1));
}