Skip to main content

is_test_file

Function is_test_file 

Source
pub fn is_test_file(path: &Path) -> bool
Expand description

Detect if a file path represents a test file based on path-based heuristics.

Checks for:

  • Directory patterns: tests/, test/, tests/, spec/
  • Filename patterns:
    • Rust: test_*.rs, *_test.rs
    • Python: test_*.py, *_test.py
    • Go: *_test.go
    • Java: Test*.java, *Test.java
    • TypeScript/JavaScript: *.test.ts, *.test.js, *.spec.ts, *.spec.js

Returns true if the path matches any test heuristic, false otherwise.