Excavator: Migrate Groovy nebula test TestDependencyVersionsTaskSpec to the new Java Junit framework
#303
+3,581
−119
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.
Is this right? TestDependencyVersionsTaskSpec.html
A formatted diff between the old and new test can be viewed here
🤖 🤖 This PR was created using Claude-code 🤖 🤖
Claude Execution Message
Claude finished running successfully.
Excellent! The migration is complete and successful. Let me now create a summary of what was accomplished:
Migration Summary
I have successfully migrated the test class
TestDependencyVersionsTaskSpec.groovytoTestDependencyVersionsTaskTest.java. Here's what was done:✅ Completed Tasks
Added delineator comments to the original Groovy test file to help reviewers compare the old and new implementations.
Migrated the test class from Groovy/Spock to Java/JUnit 5:
AbstractTestingPluginSpecto using@GradlePluginTestsannotationsetup()with JUnit's@BeforeEachrunTasksSuccessfully()withgradle.withArgs().buildsSuccessfully()applyStandardBuildWithoutGcv()to replace the build file variable from the Groovy versionTestDependencyVersions.version()API directly instead of static importsTestContentHelpers.addVersionsToPropsFile()Fixed compilation errors:
projectFile.assertThat()instead ofassertThat(file)Fileobjects toArbitraryFileobjectsApplied best practices from the testing guide:
plugins()API for adding pluginspropertiesFile().appendProperty()for properties files📝 Documentation
Created
test-migration-errors.mddocumenting:✅ Verification
The migrated test compiles successfully with
./gradlew :gradle-plugin-testing:compileTestJava.Claude Code Metrics
Migration Notes
Test Migration Errors and Solutions
This document tracks errors encountered during the migration of
TestDependencyVersionsTaskSpec.groovytoTestDependencyVersionsTaskTest.java.Initial Migration Phase
Error 1: Incorrect assertion method for File objects
Problem: Used
assertThat(outputFile)from GradlePluginTestAssertions with aFileobject, which is not supported.Error Message:
Solution: Changed from storing a
Fileobject to storing anArbitraryFile(which is returned byproject.buildDir().file()), and used itsassertThat()method:Discovery Method: Examined existing test files and read the testing guide's "File Assertions" section. Also explored the framework source code at
/tmp/gradle-plugin-testingto understand the Directory and ArbitraryFile classes.Error 2: Incorrect import for ProjectFile
Problem: Initially tried to import
ProjectFilefromcom.palantir.gradle.testing.projectpackage.Error Message:
Solution: Corrected the import to use
ArbitraryFilefromcom.palantir.gradle.testing.files.arbitrary:Discovery Method: Used grep to find the correct package location in the framework source at
/tmp/gradle-plugin-testing, and read theDirectory.javainterface to understand the return type of thefile()method.Best Practices Review Phase
Issue 3: Method chaining on single line
Problem: Chained multiple
.add()calls on a single line, which reduces readability.Solution: Split the chain across multiple lines for better readability:
Discovery Method: Reviewed the testing-guide.md examples and compared with the existing migrated test file
PluginTestingJunitPluginTest.java.Issue 4: Using old TestContentHelpers API with File objects
Problem: Called
TestContentHelpers.addVersionsToPropsFile()which requires aFileobject, forcing the use of.path().toFile()conversions.Solution: Used the fluent PropertiesFile API directly instead:
Discovery Method: Re-read the "Properties Files" section of the testing guide which explicitly states to use
appendProperty(key, value)for properties files.Summary
The main challenges were:
projectFile.assertThat()notassertThat(file))The migration was successful after addressing these issues, and the test now compiles correctly.
To enable or disable this check, please contact the maintainers of Excavator.