Skip to content

Commit 7ee8db5

Browse files
committed
#2914: let private @BeforeAll and @afterall methods fail as well
1 parent 8bffda0 commit 7ee8db5

File tree

1 file changed

+40
-6
lines changed

1 file changed

+40
-6
lines changed

junit-jupiter-engine/src/test/java/org/junit/jupiter/engine/InvalidLifecycleMethodConfigurationTests.java

+40-6
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,23 @@
3434
class InvalidLifecycleMethodConfigurationTests extends AbstractJupiterTestEngineTests {
3535

3636
@Test
37-
void executeValidTestCaseAlongsideTestCaseWithInvalidBeforeAllDeclaration() {
38-
assertExecutionResults(TestCaseWithInvalidBeforeAllMethod.class);
37+
void executeValidTestCaseAlongsideTestCaseWithInvalidNonStaticBeforeAllDeclaration() {
38+
assertExecutionResults(TestCaseWithInvalidNonStaticBeforeAllMethod.class);
3939
}
4040

4141
@Test
42-
void executeValidTestCaseAlongsideTestCaseWithInvalidAfterAllDeclaration() {
43-
assertExecutionResults(TestCaseWithInvalidAfterAllMethod.class);
42+
void executeValidTestCaseAlongsideTestCaseWithInvalidPrivateBeforeAllDeclaration() {
43+
assertExecutionResults(TestCaseWithInvalidPrivateBeforeAllMethod.class);
44+
}
45+
46+
@Test
47+
void executeValidTestCaseAlongsideTestCaseWithInvalidNonStaticAfterAllDeclaration() {
48+
assertExecutionResults(TestCaseWithInvalidNonStaticAfterAllMethod.class);
49+
}
50+
51+
@Test
52+
void executeValidTestCaseAlongsideTestCaseWithInvalidPrivateAfterAllDeclaration() {
53+
assertExecutionResults(TestCaseWithInvalidPrivateAfterAllMethod.class);
4454
}
4555

4656
@Test
@@ -90,7 +100,7 @@ void test() {
90100
}
91101
}
92102

93-
static class TestCaseWithInvalidBeforeAllMethod {
103+
static class TestCaseWithInvalidNonStaticBeforeAllMethod {
94104

95105
// must be static
96106
@BeforeAll
@@ -102,7 +112,19 @@ void test() {
102112
}
103113
}
104114

105-
static class TestCaseWithInvalidAfterAllMethod {
115+
static class TestCaseWithInvalidPrivateBeforeAllMethod {
116+
117+
// must not be private
118+
@BeforeAll
119+
private static void beforeAll() {
120+
}
121+
122+
@Test
123+
void test() {
124+
}
125+
}
126+
127+
static class TestCaseWithInvalidNonStaticAfterAllMethod {
106128

107129
// must be static
108130
@AfterAll
@@ -114,6 +136,18 @@ void test() {
114136
}
115137
}
116138

139+
static class TestCaseWithInvalidPrivateAfterAllMethod {
140+
141+
// must not be private
142+
@AfterAll
143+
private static void afterAll() {
144+
}
145+
146+
@Test
147+
void test() {
148+
}
149+
}
150+
117151
static class TestCaseWithInvalidStaticBeforeEachMethod {
118152

119153
// must NOT be static

0 commit comments

Comments
 (0)