Repository navigation
Assert the source archive itself is absent in testNoSources - #318
Merged
Merged
Conversation
Both testNoSources cases asserted that getTestTargetDir("project-005")
does not exist. That helper returns the project's target directory, not
the artifact, so the assertion does not actually check what its message
claims - and it is tied to whether a directory happens to be present
rather than to whether the mojo produced an archive.
Assert the specific jar instead, reusing the existing getSourceArchive
and getTestSourceArchive helpers so each test checks the same artifact
path its positive counterpart asserts.
Fixes apache#308
elharo
approved these changes
Aug 5, 2026
|
@elharo Please assign appropriate label to PR according to the type of change. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #308
Problem
Both
testNoSourcescases assert that no archive was produced like this:getTestTargetDirreturns the project'stargetdirectory, not the artifact. So the assertion never inspects the jar named in its own failure message — it is bound to whether a directory happens to exist rather than to whether the mojo produced an archive. A directory left behind by earlier build scaffolding, or created for unrelated reasons, is enough to change the outcome, and conversely the check cannot notice a stray jar inside a directory that does exist.Fix
Assert the specific artifact instead, reusing the helpers already on
AbstractSourcePluginTestCase:SourceJarMojoTest→getSourceArchive(getTestTargetDir("project-005"), "project-005")TestSourceJarMojoTest→getTestSourceArchive(getTestTargetDir("project-005"), "project-005")These are the same helpers the positive cases use via
assertSourceArchive/assertTestSourceArchive, so each negative test now checks exactly the path its positive counterpart asserts, and the failure message names the file that was actually examined.Testing
mvn test— 10 tests across both classes, all passing. Two lines changed, no production code touched.