private static @Nullable StackTraceElement getFirstTestElement(StackTraceElement[] stack) {
    for (StackTraceElement element : stack) {
      try {
        Class<?> clazz = Class.forName(element.getClassName());
        Method method = clazz.getMethod(element.getMethodName());
        if (isTestClass(clazz) || isTestMethod(method)) {
          return element;
        }
      } catch (NoSuchMethodException ignored) {
        // Not actionable, move onto the next element
      } catch (ClassNotFoundException ignored) {
        // Not actionable, move onto the next element
      }
    }
    return null;
  }
Get the current test name in a standard JUnit3 or JUnit4 test, or "unknown" if we couldn't
detect it.
core/src/main/java/com/facebook/testing/screenshot/internal/TestNameDetector.java