Class StackTraceTestFinderUtil

java.lang.Object
org.approvej.approve.StackTraceTestFinderUtil

@NullMarked public class StackTraceTestFinderUtil extends Object
Utility class to find the current test method using the stack trace.
  • Method Details

    • currentTestMethod

      public static TestMethod currentTestMethod()
      Finds the current test method using the stack trace.
      Returns:
      the currently executing test Method
    • findTestSourcePath

      public static Path findTestSourcePath(Method testMethod)
      Finds the source path of the test method, making the following assumptions:
      • the test class' name is also the name of the source file,
      • the base package is at most 10 levels deep,
      • the filename extension of the file is java, kt, groovy , or scala
      Parameters:
      testMethod - the test Method
      Returns:
      the Path to the source file containing the given testMethod