void (String expectedFilePath, String actualText) { String expectedText; try { if (OVERWRITE_TESTDATA) { VfsTestUtil.overwriteTestData(expectedFilePath, actualText); //noinspection UseOfSystemOutOrSystemErr System.out.println("File " + expectedFilePath + " created."); } expectedText = FileUtil.loadFile(new File(expectedFilePath), StandardCharsets.UTF_8); } catch (FileNotFoundException e) { VfsTestUtil.overwriteTestData(expectedFilePath, actualText); throw new AssertionFailedError("No output text found. File " + expectedFilePath + " created."); } catch (IOException e) { throw new RuntimeException(e); } var expectedLines = Arrays.stream(StringUtil.splitByLines(expectedText.trim(), true)) .map(s -> s.stripLeading()) .toArray(); var actualLines = Arrays.stream(StringUtil.splitByLines(actualText.trim(), true)) .map(s -> s.stripLeading()) .toArray(); if (!Arrays.equals(expectedLines, actualLines)) { throw new FileComparisonFailure(null, StringUtil.convertLineSeparators(expectedText.trim()), StringUtil.convertLineSeparators(actualText.trim()), expectedFilePath); } }