Skip to content

Conversation

@svc-excavator-bot
Copy link
Collaborator

@svc-excavator-bot svc-excavator-bot commented Jan 20, 2026

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 BaselineFormatCopyrightIntegrationTest from 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.groovy
Migrated Test: gradle-baseline-java/src/test/java/com/palantir/baseline/BaselineFormatCopyrightIntegrationTest.java

What Was Migrated

  1. 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)
  2. All supporting code:

    • Setup method to configure copyright templates
    • Static copyright string constants
    • standardBuildFile helper method
    • validJavaFile constant

Key Migration Patterns

  1. Spock → JUnit 5 Parameterized Tests: Used @ParameterizedTest with @CsvSource to replace Spock's data tables
  2. Test Method Names: Changed from 'description with #variables'() to snake_case_description
  3. Framework APIs:
    • File operations: rootProject.file(path).overwrite().append()
    • Build configuration: rootProject.buildGradle().plugins().add()
    • Gradle execution: gradle.withArgs("check").buildsWithFailure()
  4. Assertions: Used framework's fluent assertions (.failed(), .output().contains()) and AssertJ for strings

Issues Resolved

  1. Missing AssertJ import - Added for string assertions
  2. Locale specification - Used Locale.ROOT for toUpperCase()
  3. Task outcome assertions - Simplified to use .failed() shortcut

Verification

✅ 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.md

The migration is complete and ready for review!

Claude Code Metrics

Metric Value
Total cost $0.7367935999999998
Total Duration (API) 67
Total Duration (WALL) 11297
Token usage 200528 (input), 243190 (output)

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.assertThat which only works with TaskOutcome and InvocationResult.

Fix: Added import for org.assertj.core.api.Assertions.assertThat to handle String assertions.

import static org.assertj.core.api.Assertions.assertThat;

2. StringCaseLocaleUsage Error Prone check

Error: Specify a Locale when calling String#to{Lower,Upper}Case

Cause: Used lang.substring(0, 1).toUpperCase() without specifying a locale.

Fix: Added Locale.ROOT parameter:

String capitalizedLang = lang.substring(0, 1).toUpperCase(Locale.ROOT) + lang.substring(1);

Migration Approach

  1. Parameterized Tests: Converted Spock's where: blocks with data tables to JUnit 5's @ParameterizedTest with @CsvSource.

  2. Test Method Names: Changed from Spock's 'description with #variables'() to snake_case format: check_fails_on_copyright_in_project.

  3. Build File Helper: Kept the standardBuildFile pattern as a helper method returning GradleFile, as it was used in the original Groovy test.

  4. Static Variables: Converted Groovy static fields to Java private static final fields with text blocks.

  5. File Manipulation: Used the framework's fluent API:

    • rootProject.file(path).overwrite(content) instead of file(path) << content
    • rootProject.file(path).append(content) for appending
  6. Gradle Invocations:

    • with('check').buildAndFail()gradle.withArgs("check").buildsWithFailure()
    • with('format').build()gradle.withArgs("format").buildsSuccessfully()
  7. Task Assertions: Used chained assertions from the framework:

    assertThat(fail).task(":spotlessJavaCheck").outcome().isEqualTo(TaskOutcome.FAILED);
  8. 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:

assertThat(fail).task(":spotless" + capitalizedLang + "Check").outcome().isEqualTo(TaskOutcome.FAILED);

After:

assertThat(fail).task(":spotless" + capitalizedLang + "Check").failed();

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.TaskOutcome import after switching to the .failed() shortcut method.

Verification

All improvements verified with successful compilation:
./gradlew :gradle-baseline-java:compileTestJava - BUILD SUCCESSFUL


Final Review and Verification

Test Coverage

✅ All tests from the original Groovy file have been migrated:

  1. check_fails_on_copyright_in_project - 4 parameterized test cases (bad/missing × java/groovy)
  2. 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

  • ✅ All test methods migrated
  • ✅ Delineator comments added to both original and new files
  • ✅ Test names converted to snake_case
  • ✅ Parameterized tests properly configured with @CsvSource
  • ✅ Helper methods created for standardBuildFile
  • ✅ Static variables converted to constants
  • ✅ Framework's fluent APIs used correctly
  • ✅ Proper imports (both GradlePluginTestAssertions and AssertJ)
  • ✅ Shortcut assertion methods used (.failed() instead of .outcome().isEqualTo())
  • ✅ No compilation errors or warnings
  • ✅ Comments from original test preserved

Key Migration Patterns Used

  1. @ParameterizedTest with @CsvSource: Replaced Spock's where: blocks with JUnit 5 parameterized tests
  2. GradleInvoker and RootProject injection: Parameters injected into test methods (come after parameterized test parameters)
  3. Fluent file manipulation: rootProject.file(path).overwrite().append() chain
  4. Structured plugins API: rootProject.buildGradle().plugins().add("java").add("groovy")
  5. Modern assertions: Framework-specific assertions with .failed(), .output().contains(), and AssertJ for strings

No 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.

@svc-excavator-bot svc-excavator-bot force-pushed the roomba/migrate-gradle-testing-junit-framework-20f454c026d285c8 branch from cbbd4e8 to 7dba855 Compare February 1, 2026 00:54
@svc-excavator-bot svc-excavator-bot force-pushed the roomba/migrate-gradle-testing-junit-framework-20f454c026d285c8 branch from 7dba855 to 4e67760 Compare February 1, 2026 02:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant