-
Notifications
You must be signed in to change notification settings - Fork 59
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
TestsShouldNotBePublic
should not reduce visibility if test classes are extended
#309
Comments
Also occurs for Java classes that are extended: openrewrite/rewrite-kubernetes#41 |
And also for method access in GradleWrapperTest: openrewrite/rewrite#2948 |
Reducing visibilty also breaks constructs like
SomeGatewayIT cannot be referenced when it becomes non public. |
I think I found another one, someone called their |
We ran into this as well. Here is a testcase to reproduce it: @Test
void baseclassForTestsNeedsToStayPublic() {
rewriteRun(
spec -> spec.recipe(new TestsShouldNotBePublic(true)),
java(
// base class for tests should stay public
"""
package com.hello;
import org.junit.jupiter.api.BeforeEach;
public class MyTestBase {
@BeforeEach
void setUp() {
}
}
"""),
java(
// test class extends base class from another package
"""
package com.world;
import com.hello.MyTestBase;
import org.junit.jupiter.api.Test;
class MyTest extends MyTestBase {
@Test
void isWorking() {
}
}
"""));
} |
Thanks for the helpful runnable test; I've created this PR which addresses the issue and welcome a review |
…ic` (#524) * Do not reduce visibility on extended classes Fixes #309 * Update src/main/java/org/openrewrite/java/testing/cleanup/TestsShouldNotBePublic.java Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@timtebeek Awesome, that looks like a good fix, thanks for implementing it 🎉 |
TestsShouldNotBePublic should not reduce visibility of classes used in subsequent test classes, even if those are in Groovy. As seen in openrewrite/rewrite#2800.
Might be fairly niche; as such I would not consider it high priority for now.
The text was updated successfully, but these errors were encountered: