Excavator: Migrate Groovy nebula test ConfigurationCacheTest to the new Java Junit framework
#3490
+1,434
−58
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.
excavator is a bot for automating changes across repositories.
Changes produced by the roomba/migrate-gradle-testing-junit-framework check.
A formatted diff between the old and new test has been generated at test-migration-notes/ConfigurationCacheTest.html)
To view the rendered diff, copy the branch name above, click here, and then replace the BRANCH_NAME part of the URL with the branch name.
🤖 🤖 This PR was created using Claude-code 🤖 🤖
Claude Execution Message
Claude finished running successfully.
Perfect! The migration is complete and successful. Let me provide a summary:
Migration Summary
I have successfully migrated the
ConfigurationCacheTestfrom the old Nebula/Spock framework to the new Java-based testing framework. Here's what was accomplished:Files Modified/Created
Original Groovy test (
gradle-baseline-java/src/test/groovy/com/palantir/baseline/ConfigurationCacheTest.groovy):New Java test (
gradle-baseline-java/src/test/java/com/palantir/baseline/ConfigurationCacheTest.java):Migration documentation (
test-migration-errors.md):Key Migration Insights
Plugin Application Pattern: The new framework enforces using
.plugins().add()instead ofapply plugin:syntax through Error Prone checks. The framework automatically positions plugin blocks after buildscript blocks.Configuration Cache Simplification: The old framework required explicit helper methods (
runTasksWithConfigurationCacheAndCheck()), while the new framework handles this automatically whengradleTestUtils.configurationCacheEnabled = trueis set in build.gradle.All Tests Migrated: The original Groovy file contained 1 test, and all 1 test has been migrated to the Java file.
The migrated test compiles successfully and follows all the best practices outlined in the testing guide.
Claude Code Metrics
Migration Notes
Test Migration Errors and Learnings
Migration: ConfigurationCacheTest.groovy → ConfigurationCacheTest.java
Error 1: Using
apply plugin:insideappend()callsError Message:
What I Did Wrong:
I initially tried to migrate the Groovy code that used
apply plugin:inside a multi-line string passed tobuildFile <<by keeping the same pattern in Java with.append():How I Fixed It:
The new framework has an Error Prone check that enforces using the structured
.plugins().add()API instead ofapply plugin:syntax. The solution was to:buildscriptblock in anappend()call (it's not a plugin application).plugins().add()API for all plugin applicationsplugins {}block after anybuildscript {}blocksWhere I Found the Information:
.plugins().add().plugins()APIensurePluginsBlockPosition()which repositions plugins blocks after buildscript blocksObservation 1: Configuration Cache Handling
What Changed:
In the old Nebula framework, the test extended
ConfigurationCacheSpecwhich had helper methods likerunTasksWithConfigurationCacheAndCheck()that:In the new framework, configuration cache testing is automatic when
gradleTestUtils.configurationCacheEnabled = trueis set in build.gradle.Migration Pattern:
Simply call
gradle.withArgs("classes").buildsSuccessfully()and the framework automatically:UnexpectedConfigurationCacheFailureif issues are detectedThis is much simpler and more declarative than the old pattern.
Observation 2: Text Block Indentation
Best Practice:
Java text blocks should use consistent indentation that aligns with the closing
""". The framework examples show text blocks with one level of indentation:Not:
The first pattern is cleaner and easier to read.
Second Pass Review
After completing the initial migration, I reviewed the test against the testing guide and made the following improvements:
Fixed text block indentation - Reduced the indentation inside text blocks to match the pattern used in testing guide examples
Verified all best practices were followed:
Verified completeness - Confirmed all tests from the original Groovy file (1 test) were migrated to the new Java file (1 test)
No additional issues were found in the second pass.
To enable or disable this check, please contact the maintainers of Excavator.