prefer-unique-test-names
- Group
- Suspicious
- Path
lint/suspicious/prefer-unique-test-names- Default
- Off, opt in
- Origin
- Falcon
- Domain
- test
- Rule
- 416 of 512
Reports duplicate test descriptions within a group and constant names in loops.
include-methods (array of strings, default: []) adds custom test registration helpers.
Invalid
import 'package:test/test.dart';
void main() {
test('same', () {});
test('same', () {});
test("same", () {});
group('inner', () {
test('duplicate', () {});
test('duplicate', () {});
test('duplicate', () {});
});
const description = 'same';
test(description, () {});
} test('same', () {}); test('same', () {}); test('same', () {}); test("same", () {}); test('duplicate', () {}); test('duplicate', () {}); test('duplicate', () {}); test('duplicate', () {}); const description = 'same'; test(description, () {});Valid
import 'package:flutter_test/flutter_test.dart' as t;
void main() {
t.test('one', () {});
t.test('two', () {});
t.group('first', () { t.test('same', () {}); });
t.group('second', () { t.test('same', () {}); });
t.testWidgets('widget', (tester) {});
for (var i = 0; i < 2; i++) { t.test('case $i', () {}); }
void test(String name, dynamic callback) {}
test('one', () {});
}Configure prefer-unique-test-names
Set its severity in falcon.json. See the configuration guide.
{
"linter": {
"rules": {
"suspicious": {
"prefer-unique-test-names": "error"
}
}
}
}Or silence one occurrence with a suppression comment; the reason is required.
// falcon-ignore lint/suspicious/prefer-unique-test-names: <reason>More suspicious rules
- recursive-getters
recursive_gettersrecommendedFlags a getter that unconditionally returns itself.
- unnecessary-null-aware-assignments
unnecessary_null_aware_assignmentsrecommendedFlags
x ??= null, which can never have an effect. - unnecessary-null-in-if-null-operators
unnecessary_null_in_if_null_operatorsrecommendedFlags
x ?? nullandnull ?? x, where thenulloperand is redundant. - use-rethrow-when-possible
use_rethrow_when_possiblerecommendedFlags
throw einside acatch (e)by matching the exception parameter's name. - avoid-accessing-other-classes-private-members
Enforces class-level encapsulation even inside one Dart library.
- avoid-assignments-as-conditions
Flags assignments evaluated inside control-flow conditions.
- avoid-banned-annotations
Ban configured dotted annotation names, without the leading
@. - avoid-banned-exports
Ban decoded export URIs, including all conditional alternatives.