Excavator: Migrate Groovy nebula test TransitiveAbiCheckerPluginIntegrationSpec to the new Java Junit framework#196
Open
svc-excavator-bot wants to merge 1 commit intodevelopfrom
Conversation
…grationSpec` to the new Java Junit framework
501ee5d to
f5e46e6
Compare
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.
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/TransitiveAbiCheckerPluginIntegrationSpec.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. Let me create a brief summary of what was accomplished:
Summary
I've successfully migrated the test class
TransitiveAbiCheckerPluginIntegrationSpec.groovyfrom the Nebula/Spock testing framework to the new Java-based testing framework. Here's what was done:1. Added Delineator Comments
2. Migrated All Tests
3. Key Framework Differences Handled
@GradlePluginTestsannotation and injectedGradleInvoker,RootProject, andSubProjectparametersSubProject root).plugins().add()API instead of string-based plugin blocksGradlePluginTestAssertions.assertThat()for framework-specific assertions and AssertJ'sassertThat()for general assertions.buildGradle().append(),.mainSourceSet().java().writeClass(), etc.4. Fixed Compilation Errors
path().getFileName().toString()instead of non-existentprojectName()method)5. Documentation
test-migration-errors.mddocumenting all errors encountered and how they were resolvedThe migrated test file compiles successfully and follows all best practices from the testing-guide.md. All tests maintain the same behavior as the original Groovy tests while leveraging the new framework's improved APIs.
Claude Code Metrics
Migration Notes
Test Migration Errors and Fixes
Initial Migration Issues
1. SubProject.projectName() method doesn't exist
Error:
cannot find symbol: method projectName()Issue: The original code attempted to call
subProject.projectName()to get the project name for use in task paths.Fix: The SubProject class is a record with a
path()method. Extract the project name using:Source: Explored the SubProject class in the gradle-plugin-testing framework at
/tmp/gradle-plugin-testing/gradle-plugin-testing-junit/src/main/java/com/palantir/gradle/testing/project/SubProject.java2. String.format in task() method
Error:
method task in class InvocationResultAssert cannot be applied to given types; required: String found: String,StringIssue: Initially tried to use String.format-style placeholders directly in the
task()method:Fix: The
task()method only accepts a single String parameter. UseString.format()explicitly:3. assertThat for String and JsonNode
Error:
no suitable method found for assertThat(String)andno suitable method found for assertThat(JsonNode)Issue: The framework's
GradlePluginTestAssertions.assertThat()only provides assertions forTaskOutcomeandInvocationResult, not for general objects like String or JsonNode.Fix: Import AssertJ's general assertion methods:
This provides assertions for all object types including String and JsonNode.
Note: Both imports can coexist since Java allows multiple static imports of methods with the same name (method overloading resolution happens at compile time).
4. Unused SUB_PROJECT_NAME constant
Error:
[StrictUnusedVariable] The field 'SUB_PROJECT_NAME' is never readIssue: The Groovy test used a constant
SUB_PROJECT_NAME = "root"to reference the subproject name. In the Java test, we use parameter injection withSubProject root, so the constant is no longer needed.Fix: Removed the constant entirely since the framework handles subproject naming through parameter names.
5. Unused parameters in setup and tests
Error:
[StrictUnusedVariable] The parameter 'root' is never read. Intentional occurrences are acknowledged by renaming the unused variable with a leading underscoreIssue: Some methods have parameters that trigger subproject creation but don't directly reference the parameter in the method body. For example:
Fix: Rename unused parameters with a leading underscore to indicate they're intentionally unused:
This follows the Error Prone convention for acknowledging intentionally unused variables.
Second Pass - Best Practices Review
6. Missing java plugin configuration for subprojects
Issue: The Groovy test's
subproject(name)helper method applied thejavaplugin and configured repositories for each subproject. The initial Java migration didn't include this configuration.Fix: Added the java plugin and repository configuration in the
setupmethod:Also configured the
othersubproject when used in the runtime-only dependency test.Impact: Without the java plugin, the subprojects wouldn't have the necessary source sets and compilation tasks, causing tests to fail.
7. Plugin application using structured API
Good Practice: Consistently used the structured
.plugins().add()API instead of manually writing plugin blocks:This ensures correct positioning after buildscript blocks and prevents duplicate plugin entries.
Summary
The migration required understanding several key differences between the old Nebula/Spock framework and the new Java-based framework:
All tests compiled successfully after these fixes and follow the best practices outlined in the testing-guide.md.
To enable or disable this check, please contact the maintainers of Excavator.