Skip to content

Conversation

@jkschneider
Copy link
Member

@jkschneider jkschneider commented Jan 26, 2026

Summary

Several testing migration recipes were adding test dependencies without specifying scope: test, causing them to be added as implementation scope instead of testImplementation in Gradle builds.

This fix adds scope: test to the following AddDependency invocations:

  • assertj-core in JUnitToAssertj, MigrateHamcrestToAssertJ, MigrateTruthToAssertJ, TestNgToAssertj

  • hamcrest in AddHamcrestIfUsed

  • mockito-core in JMockitToMockito, EasyMockToMockito

  • vertx-junit5 in VertxUnitToVertxJunit5

  • Fixes moderneinc/customer-requests#760

Test plan

  • Build succeeds
  • Existing tests pass (AssertJBestPracticesTest, JUnitToAssertjTest, MigrateHamcrestToAssertJTest, MigrateTruthToAssertJTest, TestNgToAssertjTest)

Several testing migration recipes were adding test dependencies
(assertj-core, mockito-core, hamcrest, vertx-junit5) without
specifying scope: test. This caused the dependencies to be added
with implementation scope instead of testImplementation in Gradle
builds.

Affected recipes:
- JUnitToAssertj (assertj.yml)
- MigrateHamcrestToAssertJ (hamcrest.yml)
- AddHamcrestIfUsed (hamcrest.yml)
- MigrateTruthToAssertJ (truth.yml)
- TestNgToAssertj (testng.yml)
- JMockitToMockito (jmockit.yml)
- EasyMockToMockito (easymock.yml)
- VertxUnitToVertxJunit5 (junit5.yml)
Add tests for Maven and Gradle that verify:
- EasyMockToMockito adds mockito-core with test scope
- TestNgToAssertj adds assertj-core with test scope
- JMockitToMockito adds mockito-core with test scope
*/
package org.openrewrite.java.testing.jmockit;

import org.junit.jupiter.api.Test;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Test;
import org.openrewrite.DocumentExample;

setDefaultParserSettings(spec);
}

@Test
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@Test
@DocumentExample
@Test

This test proves that explicit scope: test is required when
test libraries are used in main sources (e.g., test utilities).
Without explicit scope, auto-detection uses compile scope.
*/
package org.openrewrite.java.testing.jmockit;

import org.junit.jupiter.api.Test;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Test;
import org.openrewrite.DocumentExample;

setDefaultParserSettings(spec);
}

@Test
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@Test
@DocumentExample
@Test

@github-project-automation github-project-automation bot moved this from In Progress to Done in OpenRewrite Jan 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant