diff --git a/src/test/java/org/checkstyle/autofix/recipe/AbstractRecipeTestSupport.java b/src/test/java/org/checkstyle/autofix/recipe/AbstractRecipeTestSupport.java index 79a9937..855f077 100644 --- a/src/test/java/org/checkstyle/autofix/recipe/AbstractRecipeTestSupport.java +++ b/src/test/java/org/checkstyle/autofix/recipe/AbstractRecipeTestSupport.java @@ -62,6 +62,8 @@ protected void verify(String testCaseName) throws Exception { final String inputPath = testCaseName.toLowerCase() + "/" + inputFileName; final String outputPath = testCaseName.toLowerCase() + "/" + outputFileName; + verifyOutputFile(outputPath); + final Configuration config = getCheckConfigurations(inputPath); final List violations = runCheckstyle(inputPath, config); @@ -95,6 +97,28 @@ private List runCheckstyle(String inputPath, } } + private void verifyOutputFile(String outputPath) throws Exception { + + final Configuration config = getCheckConfigurations(outputPath); + final List violations = runCheckstyle(outputPath, config); + if (!violations.isEmpty()) { + final StringBuilder violationMessage = + new StringBuilder("Checkstyle violations found in the output file:\n"); + + violationMessage.append("outputFile: ").append(getPath(outputPath)).append("\n"); + + for (CheckstyleViolation violation : violations) { + violationMessage + .append("line: ").append(violation.getLine()) + .append(", col: ").append(violation.getColumn()) + .append(", message: ").append(violation.getMessage()) + .append("\n"); + } + + throw new IllegalStateException(violationMessage.toString()); + } + } + private Configuration getCheckConfigurations(String inputPath) throws Exception { final String configFilePath = getPath(inputPath); final TestInputConfiguration testInputConfiguration =