getTestPath method

String getTestPath(
  1. String libPath
)

Maps a source file in lib/ to its corresponding test file in test/.

Example:

lib/features/auth/ui/login_page.dart
→ test/features/auth/ui/login_page_test.dart

Implementation

String getTestPath(String libPath) {
  final relativePath = p.relative(libPath, from: p.join(projectRoot, 'lib'));
  final fileName = p.basenameWithoutExtension(relativePath);
  final directory = p.dirname(relativePath);

  return p.join(projectRoot, 'test', directory, '${fileName}_test.dart');
}