Skip to main content

prefer-correct-test-file-name

added in: 1.6.0
Pro+
preset: recommended

Warns if a file within /test folder contains a main function, but the file name doesn't end with _test.dart.

Example

❌ Bad:

some_file.dart
// LINT: Test file name must end with '_test.dart'. Try renaming it.
void main() {
...
}

✅ Good:

some_file_test.dart
void main() {
...
}
some_other_file.dart
void helperFunction() {
...
}