Excavator: Migrate Groovy nebula test BaselineJavaCompilerDiagnosticsTest to the new Java Junit framework
#3467
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/BaselineJavaCompilerDiagnosticsTest.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.
Excellent! The migration is complete. Let me provide a summary:
Migration Complete! ✅
I've successfully migrated
BaselineJavaCompilerDiagnosticsTestfrom the Groovy/Spock/Nebula framework to the Java/JUnit 5 framework.What was migrated:
gradle-baseline-java/src/test/groovy/com/palantir/baseline/BaselineJavaCompilerDiagnosticsTest.groovygradle-baseline-java/src/test/java/com/palantir/baseline/BaselineJavaCompilerDiagnosticsTest.javaKey changes:
ProjectBuilderto integration tests using TestKit@GradlePluginTestsannotationGradleInvokerandRootProjecttest_default,test_overridden)testDefaultandtestOverriddenwere convertedTest results:
✅ All tests compile successfully
✅ All tests pass
Documentation:
Created
test-migration-errors.mddocumenting:The migration follows all the guidelines from the testing guide and uses the framework's fluent APIs correctly.
Claude Code Metrics
Migration Notes
Test Migration Errors and Learnings
Migration: BaselineJavaCompilerDiagnosticsTest.groovy → BaselineJavaCompilerDiagnosticsTest.java
Challenge 1: Unit Test vs Integration Test
Issue: The original test used
ProjectBuilder(Gradle's unit testing API) to directly inspect plugin configuration without running a build. The new framework is TestKit-based and focuses on integration testing.Resolution: Converted the unit test to an integration test by:
build.gradledoFirsthook to log compiler arguments during the buildCode Pattern:
Challenge 2: Assertion Precision
Issue: The original test checked that flags appeared exactly once and that values immediately followed the flags. In an integration test, we're verifying output text rather than inspecting data structures.
Resolution: Used
assertThat(result).output().contains()with both the flag and value. While not as precise as the original assertions, it's appropriate for integration testing and still validates the plugin's behavior.Original assertion:
New assertion:
Challenge 3: Configuration Cache Compatibility
Issue: The test was converted from a unit test to an integration test, and integration tests run with configuration cache by default in the framework.
Resolution: Added
@DisabledConfigurationCacheannotation since this is testing low-level compiler configuration that may not be fully compatible with configuration cache.Best Practices Applied
Delineation Comments: Added
// ***DELINEATOR FOR REVIEW:comments to both Groovy and Java files to help reviewers compare the structure.Test Naming: Converted from camelCase (
testDefault) to snake_case (test_default) following the new framework conventions.Assertion Descriptions: Used
.as()to add context to assertions:Text Blocks: Used Java text blocks for multi-line strings in
buildGradle().append()calls.Plugin API: Used the structured
.plugins().add()API instead of manually writing plugin blocks.Source File Creation: Used
mainSourceSet().java().writeClass()to create a simple Java file for compilation.Second Pass Review
After initial implementation, reviewed the test against the testing guide and made the following improvements:
.contains()twice to passing multiple arguments to a single.contains()call, making the assertions more concise while maintaining the same verification.Notes for Future Migrations
@DisabledConfigurationCacheannotation is useful for tests that work with low-level Gradle APIs that may not be configuration-cache compatible.To enable or disable this check, please contact the maintainers of Excavator.