discoverAndAnalyzeTests method
Implementation
List<SourceFile> discoverAndAnalyzeTests(String projectRoot) {
final testDir = Directory(p.join(projectRoot, 'test'));
if (!testDir.existsSync()) {
return [];
}
final List<SourceFile> testFiles = [];
final entities = testDir.listSync(recursive: true);
for (final entity in entities) {
if (entity is File && entity.path.endsWith('_test.dart')) {
final relativePath = p.relative(entity.path, from: projectRoot).replaceAll('\\', '/');
final content = entity.readAsStringSync();
final result = fileAnalyzer.analyzeFile(
relativePath: relativePath,
content: content,
);
testFiles.add(result.sourceFile);
}
}
return testFiles;
}