{"id":"636b4283ab137d85","repo":"junit-team/junit5","slug":"expected-file-name-with-file-extension-but-got","errorCode":null,"errorMessage":"Expected file name with file extension, but got: ${fileName}","messagePattern":"Expected file name with file extension, but got: (.+?)","errorType":"exception","errorClass":"JUnitException","httpStatus":null,"severity":"error","filePath":"junit-platform-commons/src/main/java/org/junit/platform/commons/util/SearchPathUtils.java","lineNumber":72,"sourceCode":"\t\tvar simpleClassName = determineSimpleClassName(path);\n\t\tvar parent = path.getParent();\n\t\treturn parent == null ? simpleClassName : joinPathNamesWithPackageSeparator(parent.resolve(simpleClassName));\n\t}\n\n\tprivate static String joinPathNamesWithPackageSeparator(Path path) {\n\t\treturn IntStream.range(0, path.getNameCount()) //\n\t\t\t\t.mapToObj(i -> path.getName(i).toString()) //\n\t\t\t\t.collect(joining(PACKAGE_SEPARATOR_STRING));\n\t}\n\n\tstatic String determineSimpleClassName(Path file) {\n\t\treturn removeExtension(file.getFileName().toString());\n\t}\n\n\tprivate static String removeExtension(String fileName) {\n\t\tint lastDot = fileName.lastIndexOf(FILE_NAME_EXTENSION_SEPARATOR_CHAR);\n\t\tif (lastDot < 0) {\n\t\t\tthrow new JUnitException(\"Expected file name with file extension, but got: \" + fileName);\n\t\t}\n\t\treturn fileName.substring(0, lastDot);\n\t}\n\n\tprivate static boolean isClassOrSourceFile(String name) {\n\t\treturn name.endsWith(CLASS_FILE_SUFFIX) || (SOURCE_MODE && name.endsWith(SOURCE_FILE_SUFFIX));\n\t}\n\n\tprivate static boolean isClassFile(Path file) {\n\t\treturn file.getFileName().toString().endsWith(CLASS_FILE_SUFFIX);\n\t}\n\n\tprivate SearchPathUtils() {\n\t}\n}\n","sourceCodeStart":54,"sourceCodeEnd":88,"githubUrl":"https://github.com/junit-team/junit5/blob/956246301e03d757539f7b76dd5a91f298637563/junit-platform-commons/src/main/java/org/junit/platform/commons/util/SearchPathUtils.java#L54-L88","documentation":"Error \"Expected file name with file extension, but got: ${fileName}\" thrown in junit-team/junit5.","triggerScenarios":"Thrown at junit-platform-commons/src/main/java/org/junit/platform/commons/util/SearchPathUtils.java:72 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"956246301e03d757539f7b76dd5a91f298637563","analyzedAt":"2026-08-04T19:25:17.049Z","schemaVersion":2}