isTestFile static method

bool isTestFile(
  1. String path
)

Utility to check if a file is a test file (by path).

Returns true if the file path contains '_test.dart' or is under a 'test/' directory. Handles both Unix-style (/) and Windows-style () path separators by normalizing them.

Implementation

static bool isTestFile(String path) {
  // Normalize path separators for consistent checking across platforms
  final normalizedPath = path.replaceAll('\\', '/');
  return normalizedPath.contains('_test.dart') ||
      normalizedPath.contains('/test/');
}