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/BaselineJavaCompilerDiagnosticsTest.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.

Excellent! The migration is complete. Let me provide a summary:

Migration Complete! ✅

I've successfully migrated BaselineJavaCompilerDiagnosticsTest from the Groovy/Spock/Nebula framework to the Java/JUnit 5 framework.

What was migrated:

  1. Original file: gradle-baseline-java/src/test/groovy/com/palantir/baseline/BaselineJavaCompilerDiagnosticsTest.groovy
  2. New file: gradle-baseline-java/src/test/java/com/palantir/baseline/BaselineJavaCompilerDiagnosticsTest.java

Key changes:

  1. Test approach transformation: Converted from unit tests using ProjectBuilder to integration tests using TestKit
  2. Test structure:
    • ✅ Used @GradlePluginTests annotation
    • ✅ Parameter injection for GradleInvoker and RootProject
    • ✅ Converted test names to snake_case (test_default, test_overridden)
  3. Verification strategy: Added lifecycle logging to output compiler args during build, then verified them in the output
  4. All tests migrated: Both testDefault and testOverridden were converted
  5. Delineation comments: Added review markers to both original and new files for easy comparison

Test results:

✅ All tests compile successfully
✅ All tests pass

Documentation:

Created test-migration-errors.md documenting:

  • The challenges encountered during migration
  • How unit tests using ProjectBuilder should be converted to integration tests
  • Best practices applied
  • Patterns for verifying compiler configuration in integration tests

The migration follows all the guidelines from the testing guide and uses the framework's fluent APIs correctly.

Claude Code Metrics

Metric Value
Total cost $0.55285285
Total Duration (API) 101
Total Duration (WALL) 8497
Token usage 159407 (input), 219505 (output)

Migration Notes

Test Migration Errors and Learnings

Migration: BaselineJavaCompilerDiagnosticsTest.groovy → BaselineJavaCompilerDiagnosticsTest.java

Challenge 1: Unit Test vs Integration Test

Issue: The original test used ProjectBuilder (Gradle's unit testing API) to directly inspect plugin configuration without running a build. The new framework is TestKit-based and focuses on integration testing.

Resolution: Converted the unit test to an integration test by:

  1. Applying plugins through build.gradle
  2. Adding a doFirst hook to log compiler arguments during the build
  3. Verifying the output contains the expected flags and values

Code Pattern:

rootProject.buildGradle().append("""
    tasks.withType(JavaCompile).configureEach {
        doFirst {
            logger.lifecycle("allCompilerArgs: {}", options.allCompilerArgs)
        }
    }
    """);

Challenge 2: Assertion Precision

Issue: The original test checked that flags appeared exactly once and that values immediately followed the flags. In an integration test, we're verifying output text rather than inspecting data structures.

Resolution: Used assertThat(result).output().contains() with both the flag and value. While not as precise as the original assertions, it's appropriate for integration testing and still validates the plugin's behavior.

Original assertion:

allJvmArgs.stream().filter('-Xmaxerrs'::equals).count() == 1
allJvmArgs.get(allJvmArgs.indexOf('-Xmaxerrs') + 1) == '10000'

New assertion:

assertThat(result)
    .output()
    .as("Xmaxerrs should be set to 10000")
    .contains("-Xmaxerrs", "10000");

Challenge 3: Configuration Cache Compatibility

Issue: The test was converted from a unit test to an integration test, and integration tests run with configuration cache by default in the framework.

Resolution: Added @DisabledConfigurationCache annotation since this is testing low-level compiler configuration that may not be fully compatible with configuration cache.

Best Practices Applied

  1. Delineation Comments: Added // ***DELINEATOR FOR REVIEW: comments to both Groovy and Java files to help reviewers compare the structure.

  2. Test Naming: Converted from camelCase (testDefault) to snake_case (test_default) following the new framework conventions.

  3. Assertion Descriptions: Used .as() to add context to assertions:

    .as("Xmaxerrs should be set to 10000")
  4. Text Blocks: Used Java text blocks for multi-line strings in buildGradle().append() calls.

  5. Plugin API: Used the structured .plugins().add() API instead of manually writing plugin blocks.

  6. Source File Creation: Used mainSourceSet().java().writeClass() to create a simple Java file for compilation.

Second Pass Review

After initial implementation, reviewed the test against the testing guide and made the following improvements:

  1. Simplified assertions: Changed from chaining .contains() twice to passing multiple arguments to a single .contains() call, making the assertions more concise while maintaining the same verification.

Notes for Future Migrations

  1. ProjectBuilder tests should generally be converted to integration tests using the new framework.
  2. When verifying compiler/task configuration, use lifecycle logging to output the configuration during the build and verify it in the output.
  3. Remember to add a simple source file (like a Hello World class) when testing compiler plugins, as compilation tasks need source to compile.
  4. The framework's @DisabledConfigurationCache annotation is useful for tests that work with low-level Gradle APIs that may not be configuration-cache compatible.

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-efb8700aee606c89 branch from d9604b7 to 00d93c5 Compare January 20, 2026 17:02
@svc-excavator-bot svc-excavator-bot force-pushed the roomba/migrate-gradle-testing-junit-framework-efb8700aee606c89 branch from 00d93c5 to 788d647 Compare February 1, 2026 02:40
@svc-excavator-bot svc-excavator-bot force-pushed the roomba/migrate-gradle-testing-junit-framework-efb8700aee606c89 branch from 788d647 to a800521 Compare February 1, 2026 02:43
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