Skip to main content

prefer_mirror_test_structure

Warns when the test file folder structure does not mirror the 'lib/' folder structure of the imported implementation file.

Keeping the same folder structure for your tests makes it easier to locate test files and allows using IDE commands such as 'Go to Test/Implementation File'.

This rule highlights test files that import implementation files with the same name (without the _test suffix) when their relative directory path in test/ does not match the relative directory path in lib/.

Example​

BAD:​

File: test/auth_service_test.dart

import 'package:my_app/src/services/auth_service.dart'; // LINT

GOOD:​

File: test/src/services/auth_service_test.dart

import 'package:my_app/src/services/auth_service.dart'; // OK