-
Notifications
You must be signed in to change notification settings - Fork 101
Add scope: test to AddDependency invocations for test libraries #896
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| import org.junit.jupiter.api.Test; | |
| import org.junit.jupiter.api.Test; | |
| import org.openrewrite.DocumentExample; |
| setDefaultParserSettings(spec); | ||
| } | ||
|
|
||
| @Test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| @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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| import org.junit.jupiter.api.Test; | |
| import org.junit.jupiter.api.Test; | |
| import org.openrewrite.DocumentExample; |
| setDefaultParserSettings(spec); | ||
| } | ||
|
|
||
| @Test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| @Test | |
| @DocumentExample | |
| @Test |
Summary
Several testing migration recipes were adding test dependencies without specifying
scope: test, causing them to be added asimplementationscope instead oftestImplementationin Gradle builds.This fix adds
scope: testto the followingAddDependencyinvocations:assertj-corein JUnitToAssertj, MigrateHamcrestToAssertJ, MigrateTruthToAssertJ, TestNgToAssertjhamcrestin AddHamcrestIfUsedmockito-corein JMockitToMockito, EasyMockToMockitovertx-junit5in VertxUnitToVertxJunit5Fixes moderneinc/customer-requests#760
Test plan