Excavator: Migrate Groovy nebula test BaselineFormatCopyrightIntegrationTest to the new Java Junit framework
#3459
+4,411
−157
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/BaselineFormatCopyrightIntegrationTest.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! Let me create a summary of the migration:
Migration Complete! ✅
I have successfully migrated the test class
BaselineFormatCopyrightIntegrationTestfrom the Groovy/Nebula framework to the new Java-based testing framework.Summary of Changes
Original Test:
gradle-baseline-java/src/test/groovy/com/palantir/baseline/BaselineFormatCopyrightIntegrationTest.groovyMigrated Test:
gradle-baseline-java/src/test/java/com/palantir/baseline/BaselineFormatCopyrightIntegrationTest.javaWhat Was Migrated
2 test methods covering 10 test cases total:
check_fails_on_copyright_in_project- Tests that check fails on bad/missing copyright (4 cases)check_passes_on_correct_copyright_in_project- Tests that check passes on correct copyright (6 cases)All supporting code:
standardBuildFilehelper methodvalidJavaFileconstantKey Migration Patterns
@ParameterizedTestwith@CsvSourceto replace Spock's data tables'description with #variables'()tosnake_case_descriptionrootProject.file(path).overwrite().append()rootProject.buildGradle().plugins().add()gradle.withArgs("check").buildsWithFailure().failed(),.output().contains()) and AssertJ for stringsIssues Resolved
Locale.ROOTfortoUpperCase().failed()shortcutVerification
✅ Test compiles successfully with no errors or warnings
✅ All delineator comments added for review
✅ Follows all best practices from the testing guide
✅ Documentation of issues and fixes in
test-migration-errors.mdThe migration is complete and ready for review!
Claude Code Metrics
Migration Notes
Test Migration Errors and Fixes
Migration of BaselineFormatCopyrightIntegrationTest
Initial Issues Found
1. Wrong assertThat import for String assertions
Error:
no suitable method found for assertThat(String)when trying to assert on file text content.Cause: Was only importing
com.palantir.gradle.testing.assertion.GradlePluginTestAssertions.assertThatwhich only works withTaskOutcomeandInvocationResult.Fix: Added import for
org.assertj.core.api.Assertions.assertThatto handle String assertions.2. StringCaseLocaleUsage Error Prone check
Error:
Specify a Locale when calling String#to{Lower,Upper}CaseCause: Used
lang.substring(0, 1).toUpperCase()without specifying a locale.Fix: Added
Locale.ROOTparameter:Migration Approach
Parameterized Tests: Converted Spock's
where:blocks with data tables to JUnit 5's@ParameterizedTestwith@CsvSource.Test Method Names: Changed from Spock's
'description with #variables'()to snake_case format:check_fails_on_copyright_in_project.Build File Helper: Kept the
standardBuildFilepattern as a helper method returningGradleFile, as it was used in the original Groovy test.Static Variables: Converted Groovy static fields to Java
private static finalfields with text blocks.File Manipulation: Used the framework's fluent API:
rootProject.file(path).overwrite(content)instead offile(path) << contentrootProject.file(path).append(content)for appendingGradle Invocations:
with('check').buildAndFail()→gradle.withArgs("check").buildsWithFailure()with('format').build()→gradle.withArgs("format").buildsSuccessfully()Task Assertions: Used chained assertions from the framework:
Copyright Templates: The
${today.year}syntax in copyright templates is intentionally preserved as-is, since this is the template syntax that the baseline-format plugin uses.Compilation Status
✅ Test file compiles successfully with no errors or warnings.
Second Pass Review - Best Practices Improvements
After reviewing the testing guide again, I identified and made the following improvements:
1. Simplified Task Outcome Assertions
Before:
After:
Reason: The framework provides convenient shortcut methods like
.failed(),.succeeded(),.upToDate()etc. These are more readable and concise than using.outcome().isEqualTo(TaskOutcome.FAILED).2. Removed Unused Import
Removed the
org.gradle.testkit.runner.TaskOutcomeimport after switching to the.failed()shortcut method.Verification
All improvements verified with successful compilation:
✅
./gradlew :gradle-baseline-java:compileTestJava- BUILD SUCCESSFULFinal Review and Verification
Test Coverage
✅ All tests from the original Groovy file have been migrated:
check_fails_on_copyright_in_project- 4 parameterized test cases (bad/missing × java/groovy)check_passes_on_correct_copyright_in_project- 6 parameterized test cases (3 copyright types × java/groovy)Total: 2 test methods covering 10 test cases
Migration Completeness Checklist
Key Migration Patterns Used
where:blocks with JUnit 5 parameterized testsrootProject.file(path).overwrite().append()chainrootProject.buildGradle().plugins().add("java").add("groovy").failed(),.output().contains(), and AssertJ for stringsNo Issues Found in Third Pass
The test is complete and follows all best practices from the testing guide.
To enable or disable this check, please contact the maintainers of Excavator.