Class FileFinder


  • public class FileFinder
    extends java.lang.Object
    Locates source files for test classes in various common directory structures. This class searches through standard Maven/Gradle directory layouts to find the corresponding .java source file for a given test class.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String extractRelativeFilePath​(java.lang.String filepath)
      Extracts package-relative file path from full file path.
      java.lang.String getPath​(org.junit.jupiter.api.extension.ExtensionContext context)  
      java.lang.String getTestClassFilePath​(java.lang.Class<?> testClass)
      Finds the source file path for the given test class.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • FileFinder

        public FileFinder()
      • FileFinder

        public FileFinder​(PathNormalizer normalizer)
        Constructor for testing
        Parameters:
        normalizer - the path normalizer
    • Method Detail

      • getTestClassFilePath

        public java.lang.String getTestClassFilePath​(java.lang.Class<?> testClass)
        Finds the source file path for the given test class. Searches through common source directory structures including Maven and Gradle layouts.
        Parameters:
        testClass - the test class to locate
        Returns:
        the file path to the source file, or null if not found
      • getPath

        public java.lang.String getPath​(org.junit.jupiter.api.extension.ExtensionContext context)
      • extractRelativeFilePath

        public java.lang.String extractRelativeFilePath​(java.lang.String filepath)
        Extracts package-relative file path from full file path. Updated to work similarly to TestNgFileFinder but for JUnit context.
        Parameters:
        filepath - the full file path to process
        Returns:
        the relative file path from the package root, or "UnknownFile.java" if path is invalid