Skip to content

Commit

Permalink
Only RemoveTestPrefix for camel or snake case
Browse files Browse the repository at this point in the history
Fixes #471
  • Loading branch information
timtebeek committed Jan 24, 2024
1 parent 6b5fd4f commit b5b0c84
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public J.MethodDeclaration visitMethodDeclaration(J.MethodDeclaration method,
int nameLength = simpleName.length();
if (nameLength < 5
|| !simpleName.startsWith("test")
|| !(simpleName.charAt(4) == '_' || Character.isUpperCase(simpleName.charAt(4)))
|| TypeUtils.isOverride(method.getMethodType())
|| !hasJUnit5MethodAnnotation(method)) {
return m;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.junit.jupiter.api.Test;
import org.openrewrite.DocumentExample;
import org.openrewrite.InMemoryExecutionContext;
import org.openrewrite.Issue;
import org.openrewrite.java.JavaParser;
import org.openrewrite.test.RecipeSpec;
import org.openrewrite.test.RewriteTest;
Expand Down Expand Up @@ -292,4 +293,27 @@ static Stream<Arguments> testMyDoSomethingLogic() {
)
);
}

@Test
@Issue("https://github.com/openrewrite/rewrite-testing-frameworks/issues/471")
void ignoreTestingAsPrefix() {
//language=java
rewriteRun(
java(
"""
import org.junit.jupiter.api.Test;
class ATest {
@Test
void testingEnvironment() {
}
@Test
void tests() {
}
}
"""
)
);
}
}

0 comments on commit b5b0c84

Please sign in to comment.