Skip to content

Conversation

@svc-excavator-bot
Copy link
Collaborator

@svc-excavator-bot svc-excavator-bot commented Nov 24, 2025

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/PalantirJavaFormatIdeaPluginTest.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 provide a summary of what was done:

Migration Summary

I've successfully migrated the test class from Nebula/Spock (Groovy) to the new Java-based testing framework. Here's what was completed:

Changes Made:

  1. Added delineator comments to the original Groovy test for easier comparison during review (in /repo/gradle-palantir-java-format/src/test/groovy/com/palantir/javaformat/gradle/PalantirJavaFormatIdeaPluginTest.groovy)

  2. Created the new Java test at /repo/gradle-palantir-java-format/src/test/java/com/palantir/javaformat/gradle/PalantirJavaFormatIdeaPluginTest.java with:

    • @GradlePluginTests annotation instead of extending IntegrationTestKitSpec
    • Parameter injection for GradleInvoker and RootProject
    • Converted Spock's parameterized test (where clause) into two separate test methods for clarity
    • Used structured plugins() API instead of apply plugin strings
    • Used appendProperty() for gradle properties file
    • Maintained all delineator comments for review purposes
    • Proper exception handling with UncheckedIOException
  3. Verified compilation - the test compiles successfully

  4. Created error tracking file at /repo/test-migration-errors.md documenting:

    • All compilation errors encountered and how they were resolved
    • Review findings and decisions made
    • References to where I found the information to fix issues

Key Migration Decisions:

  • Split the parameterized Spock test into two separate @Test methods instead of using @ParameterizedTest, as this provides clearer test names and simpler logic
  • Kept the XML parsing logic largely the same since the framework doesn't provide specialized XML assertions
  • Used the structured plugins API as enforced by Error Prone checks
  • Maintained all original test coverage with both scenarios (with and without native formatter)

The migrated test follows all the best practices from the testing guide and compiles successfully!

Claude Code Metrics

Metric Value
Total cost $0.6441498499999998
Total Duration (API) 90
Total Duration (WALL) 11911
Token usage 272217 (input), 304751 (output)

Migration Notes

Test Migration Errors and Fixes

Initial Migration Pass

Error 1: RuntimeException instead of UncheckedIOException

Issue: Used RuntimeException when wrapping IOException in readNativeImageFile() method.
Error Message:

error: [PreferUncheckedIoException] Prefer UncheckedIOException or SafeUncheckedIoException when wrapping IOException so consumers can more accurately categorize errors

Fix: Changed from throw new RuntimeException("Failed to read native image file", e); to throw new UncheckedIOException("Failed to read native image file", e);
Source: Error Prone check caught this during compilation.

Error 2: Using append() instead of structured plugins() API

Issue: Attempted to use apply plugin: 'idea' within an append() call instead of using the structured plugins API.
Error Message:

error: [GradleTestPluginsBlock] Plugins must be added using .plugins().add() method. Use gradleFile.plugins().add("plugin-id") instead.

Fix: Changed from:

rootProject.buildGradle().plugins().add("com.palantir.java-format-idea");
rootProject.buildGradle().append("""
    apply plugin: 'idea'
    ...
""");

To:

rootProject.buildGradle()
    .plugins()
    .add("com.palantir.java-format-idea")
    .add("idea");

Source: Error Prone check from the testing framework. Also mentioned in testing-guide.md under "Plugin Management".

Error 3: Parameterized test complexity

Issue: Initially tried to use JUnit's @ParameterizedTest with @CsvSource to replicate Spock's where clause, but this caused issues with string handling and Error Prone checks.
Fix: Split the test into two separate methods:

  • idea_configures_xml_files() - tests without native formatter
  • idea_configures_xml_files_with_native_formatter() - tests with native formatter

This approach is cleaner and more explicit than trying to force parameterization for this use case.
Source: Trial and error during initial compilation attempts.

Review Pass 1

Review Item 1: Text Blocks

Issue: Need to ensure text blocks have blank lines after them for clarity.
Status: ✓ Text blocks properly formatted with blank lines in both test methods.

Review Item 2: Use of String.format

Issue: Need to verify the String.format syntax is used correctly with the append() method.
Status: ✓ Using varargs format correctly: .append("""...""", NATIVE_CONFIG)

Review Item 3: Assertion Chaining

Issue: Could potentially chain assertions when checking multiple things on XML parsing results.
Status: Current approach is acceptable. The assertions are separate because they check different boolean flags with different descriptive messages. Chaining wouldn't provide a benefit here.

Review Item 4: File Path Construction

Issue: Using .path() to get Path object when we might be able to use framework file assertions directly.
Status: Current approach is necessary because we need to parse XML files using standard Java XML parsing APIs. The framework doesn't provide XML-specific assertions, so using .path() to get the Path object for XML parsing is appropriate.

Review Pass 2

No additional issues found. The test:

  • ✓ Uses @GradlePluginTests annotation
  • ✓ Uses parameter injection correctly (GradleInvoker, RootProject)
  • ✓ Uses structured plugins() API
  • ✓ Uses proper text blocks with formatting
  • ✓ Follows snake_case naming convention for test methods
  • ✓ Uses appendProperty for gradle properties
  • ✓ Includes all delineator comments from original Groovy test
  • ✓ Compiles successfully
  • ✓ Maintains the same test coverage as the original Groovy test

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-49704917f796429b branch from 336c497 to 6a0bb9d Compare November 25, 2025 18:51
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.

2 participants