Let the setUp methods actually run - #587
Merged
Merged
Conversation
Neither AbstractModelloGeneratorTest.setUp() nor its override in AbstractModelloJavaGeneratorTest carried @beforeeach, so under JUnit Jupiter neither was ever called. Both delete and recreate the test's output directory, which meant target/generator-results/<name> was never cleaned between runs and generated classes from an earlier run could survive into a later one and hide a failure. The directories existed at all only because the compiler happened to create them. Annotating them is not quite enough on its own: the java override does not call super, so the sources directory would still go untouched. It now chains, and the two levels clean the two directories they each own. AbstractStaxGeneratorTestCase existed only to add the annotation and delegate to super - the workaround for this bug in the one place it was noticed. It is no longer needed. Verified by putting an unconditional throw at the top of the base setUp: on master the affected modules still pass, which is only possible if the method never runs; with this change the same probe fails every test that inherits it, through both the direct and the chained path. Generated-by: Claude Opus 5 (1M context)
slachiewicz
marked this pull request as ready for review
August 10, 2026 00:41
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.
Follow-up to #584, where this turned up while debugging a Java 8 failure. It predates that PR and #583 — both methods were already unannotated before either.
Neither
AbstractModelloGeneratorTest.setUp()nor its override inAbstractModelloJavaGeneratorTestcarries@BeforeEach, so under Jupiter neither has been called at all. Both delete and recreate the test's output directory, sotarget/generator-results/<name>is never cleaned between runs and generated classes from an earlier run can survive into a later one and hide a failure. Those directories existed only because the compiler happened to create them — which is exactly how #584 surfaced it, sincejavax.toolson Java 8 will not create a-dthat is missing.Annotating is not quite enough on its own. The java override does not call
super, so thesourcesdirectory would still go untouched; it now chains, and the two levels clean the two directories they each own.AbstractStaxGeneratorTestCaseexisted only to add@BeforeEachand delegate tosuper.setUp()— the workaround for this bug, in the one place someone noticed the symptom. It is removed.Evidence that it really was dead
Rather than argue from reading the code, I put an unconditional
throw new IllegalStateExceptionat the top of the basesetUp()and ran the suite:modello-plugin-javamodello-plugin-xdocmasterA method that throws unconditionally cannot be executing. The second row also confirms both paths reach it: xdoc extends the base directly, java reaches it through the new
super.setUp()chain.Verification
mvn installwith tests, everygenerator-resultsdirectory deleted first: exit 0, 120 tests, zero failures and zero errors across all 14 modules.spotless:checkclean.Use
installorverifyrather thanmvn testhere — see my comment on #584 for whymvn testreports 5 spurious NPEs on any branch.Draft until CI confirms, jdk-8 included.
Generated-by: Claude Opus 5 (1M context)