String (final @NotNull Path path) { Path absPath = path.toAbsolutePath(); String fileName = absPath.getFileName().toString(); if (!FileUtilRt.extensionEquals(fileName, "class")) { return null; } if (!includeUnconventionallyNamedTests) { if (fileName.endsWith("Test.class")) { return getClassFQN(absPath); } } else { String nestedClassName = FileUtilRt.getNameWithoutExtension(fileName); List<String> names = Arrays.asList(nestedClassName.split("\\$")); Collections.reverse(names); for (String className : names) { // most likely something like RecursionManagerTest$_testMayCache_closure5 or other anonymous class // may cause https://issues.apache.org/jira/browse/GROOVY-5351 if (!Character.isUpperCase(className.charAt(0))) return null; // A test may be named Test*, *Test, *Tests*, *TestCase, *TestSuite, *Suite, etc List<String> words = Arrays.asList(NameUtilCore.nameToWords(className)); if (words.contains("Test") || words.contains("Tests") || words.contains("Suite")) { return getClassFQN(absPath); } } } return null; }