Skip to content

Excavator: Migrate Groovy nebula test MainClassInferenceIntegrationSpec to the new Java Junit framework#1945

Open
svc-excavator-bot wants to merge 1 commit intodevelopfrom
roomba/migrate-gradle-testing-junit-framework-e95ff3c1decb9120
Open

Excavator: Migrate Groovy nebula test MainClassInferenceIntegrationSpec to the new Java Junit framework#1945
svc-excavator-bot wants to merge 1 commit intodevelopfrom
roomba/migrate-gradle-testing-junit-framework-e95ff3c1decb9120

Conversation

@svc-excavator-bot
Copy link
Copy Markdown
Collaborator

@svc-excavator-bot svc-excavator-bot commented Jan 1, 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/MainClassInferenceIntegrationSpec.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 🤖 🤖

Model: opus


Claude Execution Message

Claude finished running successfully.

The migration is complete. Here's a summary of what was done:

Files Modified

  • gradle-sls-packaging/src/test/groovy/com/palantir/gradle/dist/service/MainClassInferenceIntegrationSpec.groovy - Added ***DELINEATOR FOR REVIEW comments to delineate methods, variables, and test sections (when/then blocks)

Files Created

  • gradle-sls-packaging/src/test/java/com/palantir/gradle/dist/service/MainClassInferenceIntegrationTest.java - Migrated test class
  • test-migration-errors.md - Migration log documenting decisions and any issues

Migration Summary

All 3 tests were migrated from the Groovy Spock framework to Java JUnit 5:

Original (Groovy) Migrated (Java)
infers main class correctly infers_main_class_correctly
fails to infer main class if there are many fails_to_infer_main_class_if_there_are_many
allows users to override main class if there are many allows_users_to_override_main_class_if_there_are_many

Key patterns applied:

  • @GradlePluginTests + @DisabledConfigurationCache annotations
  • Plugin application via structured .plugins().add() API
  • Multi-version testing handled automatically (removed where: blocks)
  • Failure testing via buildsWithFailure() + output assertions
  • .as() descriptions on assertions for self-documenting failure messages
  • Helper methods (unTarTask, mainClass, schemaClass) take parameters instead of using instance fields

Claude Code Metrics

Metric Value
Total cost $1.5646463
Total Duration (API) 332642 ms
Total Duration (WALL) 346245 ms
Token usage 3445 (input), 16718 (output)
Cached tokens 56453 (creation), 1372074 (read)

Migration Notes

Test Migration Errors - MainClassInferenceIntegrationSpec

Migration: MainClassInferenceIntegrationSpec → MainClassInferenceIntegrationTest

First Pass

No compilation errors were encountered during the initial migration. The test compiled successfully on the first attempt.

Key Migration Decisions

  1. Plugin application: Moved plugins { id 'java'; id 'com.palantir.sls-java-service-distribution' } from a text block in the Groovy setup() to structured .plugins().add("java").add("com.palantir.sls-java-service-distribution") in the @BeforeEach method.

  2. Failure test pattern: The original Groovy test used thrown(UnexpectedBuildFailure) with error.message.contains(...). Migrated to buildsWithFailure() + assertThat(result).output().contains(...) which is the idiomatic pattern in the new framework.

  3. unTarTask helper: The original Groovy method returned a String that was interpolated into a larger build file string via ${unTarTask('service-name')}. Converted to a void helper method that directly appends to the build file using rootProject.buildGradle().append(...) with String.format style %s parameter, following the existing pattern in JavaServiceDistributionPluginTests.createUntarTask().

  4. Java source file helpers: Kept mainClass() and schemaClass() as static String-returning methods, passing their output to rootProject.mainSourceSet().java().writeClass(...).

  5. Multi-version testing: The original used Spock where: blocks with GradleTestVersions.GRADLE_VERSIONS. Removed this entirely since @GradlePluginTests automatically handles multi-version testing.

Second Pass Review

Reviewed the test against the testing-guide.md and migration instructions. No changes were needed - all best practices were already followed in the first pass.

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-e95ff3c1decb9120 branch 3 times, most recently from ed5acfa to cb1b3f8 Compare February 6, 2026 11:45
@svc-excavator-bot svc-excavator-bot force-pushed the roomba/migrate-gradle-testing-junit-framework-e95ff3c1decb9120 branch from cb1b3f8 to ce43fe7 Compare March 1, 2026 03:47
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