Skip to content
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

Check that @TestTemplate methods are not public or private #138

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@ public class SpringJUnit5Check extends AbstractSpringCheck {

private static final String JUNIT5_TEST_ANNOTATION = "org.junit.jupiter.api.Test";

private static final String JUNIT5_TEST_TEMPLATE_ANNOTATION = "org.junit.jupiter.api.TestTemplate";

private static final List<String> TEST_ANNOTATIONS = Collections
.unmodifiableList(Arrays.asList("Test", JUNIT4_TEST_ANNOTATION, JUNIT5_TEST_ANNOTATION));
.unmodifiableList(Arrays.asList("Test", "TestTemplate", JUNIT4_TEST_ANNOTATION, JUNIT5_TEST_ANNOTATION,
JUNIT5_TEST_TEMPLATE_ANNOTATION));

private static final List<String> LIFECYCLE_ANNOTATIONS = Collections.unmodifiableList(Arrays.asList("BeforeAll",
"org.junit.jupiter.api.BeforeAll", "BeforeEach", "org.junit.jupiter.api.BeforeEach", "AfterAll",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
+Test method 'doSomethingWorks' should not be public
+Test method 'doSomethingElseWorks' should not be private
+Test method 'doSomethingWithTemplateWorks' should not be public
+Test method 'doSomethingElseWithTemplateWorks' should not be private
+Lifecycle method 'publicBeforeAll' should not be public
+Lifecycle method 'publicBeforeEach' should not be public
+Lifecycle method 'publicAfterAll' should not be public
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,14 @@ private void doSomethingElseWorks() {
// test here
}

@TestTemplate
public void doSomethingWithTemplateWorks() {
// test here
}

@TestTemplate
private void doSomethingElseWithTemplateWorks() {
// test here
}

}