Copilot commented on code in PR #712:
URL:
https://github.com/apache/maven-checkstyle-plugin/pull/712#discussion_r4248063379
##########
src/test/java/org/apache/maven/plugins/checkstyle/CheckstyleViolationCheckMojoTest.java:
##########
@@ -92,6 +95,19 @@ public void testNoOutputFile(CheckstyleViolationCheckMojo
mojo) throws Exception
mojo.execute();
}
+ @InjectMojo(goal = "check", pom =
"src/test/resources/plugin-configs/no-source-check-plugin-config.xml")
+ @Test
+ public void
testNoSourceDoesNotCreateOutputFiles(CheckstyleViolationCheckMojo mojo) throws
Exception {
+ project.setPackaging("pom");
+ mojo.execute();
+
+ File outputDirectory = new
File("target/test-harness/checkstyle/no-source-check");
+ assertFalse(new File(outputDirectory,
"checkstyle-cachefile").exists());
+ assertFalse(new File(outputDirectory,
"checkstyle-checker.xml").exists());
+ assertFalse(new File(outputDirectory,
"checkstyle-header.txt").exists());
+ assertFalse(new File(outputDirectory,
"checkstyle-result.xml").exists());
+ }
Review Comment:
This test hard-codes a relative path (`target/...`) and does not clean up
any pre-existing outputs, which can make it flaky depending on the working
directory and prior test runs. Prefer building the path from the test project's
basedir (e.g., `project.getBasedir()`) and deleting the output directory (or at
least the specific files) before `mojo.execute()`. Also consider asserting the
output directory itself was not created if the intent is 'no artifacts at all'.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]