Excavator: Migrate Groovy nebula test LocalFailuresRecommendationsIntegrationSpec to the new Java Junit framework
#431
+1,482
−68
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/LocalFailuresRecommendationsIntegrationSpec.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 test has been successfully migrated and is working correctly. All the files are generated properly with:
Let me create a summary of the migration:
Summary
I have successfully migrated the test class
LocalFailuresRecommendationsIntegrationSpec.groovytoLocalFailuresRecommendationsIntegrationTest.java. Here's what was accomplished:Changes Made:
Added delineator comments to the original Groovy test file for easier review comparison
Created the new Java test file with the following key changes:
IntegrationSpecbase class to@GradlePluginTestsannotationreproduce_gradle_issues_10483buildFile <<to fluent API:rootProject.buildGradle().plugins().add()file('gradle.properties') <<torootProject.gradlePropertiesFile().appendProperty()addSubproject()to parameter injection:SubProject myProjectrunTasksWithFailure()togradle.withArgs().buildsWithFailure()result.standardError.contains()to chainedassertThat(result).output().contains()result.failure.causes.size() == 3with explicit task failure checksCompilation: The test compiles successfully. Fixed Error Prone issues about using
.plugins().add()instead of manually appending plugin blocks.Testing: The test runs successfully and generates the expected project structure.
Documentation: Created
test-migration-errors.mddocumenting all errors encountered and how they were resolved.Test Verification:
The migrated test follows all the guidelines from the testing-guide.md and uses the new framework's fluent APIs correctly.
Claude Code Metrics
Migration Notes
Test Migration Errors and Fixes
Migration of LocalFailuresRecommendationsIntegrationSpec to LocalFailuresRecommendationsIntegrationTest
First Pass - Initial Migration
Error 1: Using append() for plugin application
Error Message:
Problem: Initially wrote plugin application using
append()with string content:Fix: Changed to use the structured
.plugins().add()API as documented in the testing guide:How I found the solution: The Error Prone check provided a clear message. This is also documented in the testing guide under "Plugin Management" section which states: "Always use the
plugins()API instead of manually writing plugin blocks inappend()oroverwrite()calls."Error 2: Similar issue with java plugin
Problem: Same issue for the subproject's java plugin application.
Fix: Changed from:
To:
Second Pass - Review Against Testing Guide
Observation 1: Multi-version testing
Original test behavior: Used Spock's data tables with
where: gradleVersionNumber << List.of("8.8")to test against Gradle 8.8.New framework behavior: The new framework automatically handles multi-version testing via the
gradleTestUtilsextension configuration. No code changes needed in the test itself - this is configured at the build level.Decision: No changes needed. The framework's automatic multi-version testing is superior to the old approach.
Observation 2: Checking failure causes
Original test: Used
result.failure.causes.size() == 3to check that there were 3 failures (two task failures + overall build failure).New framework approach: The new framework doesn't expose
failure.causes. Instead, I verify each task failure individually:This is semantically equivalent and more explicit about what we're checking.
Observation 3: Error output checking
Original test: Used
result.standardError.contains()to check error messages.New framework: Uses
result.output()which returns combined stdout and stderr. The assertions work the same way:Benefit: The new approach uses chained assertions which is cleaner and provides better failure messages.
Third Pass - Final Review
No additional changes needed. The test:
@GradlePluginTestsannotation.plugins().add()for plugin applicationbuildsWithFailure()Summary
The migration was straightforward. The main changes were:
The new test is more maintainable and type-safe while maintaining the same test coverage.
To enable or disable this check, please contact the maintainers of Excavator.