Skip to content

Commit 7ee76c2

Browse files
committed
Fix HierarchyTestCase re: static @BeforeAll/@afterall
This commit comments out @BeforeAll/@afterall declarations in @nested test classes until issue #88 is resolved. Issue: #88 ------------------------------------------------------------------------ On behalf of the community, the JUnit Lambda Team thanks msg systems ag (http://www.msg-systems.com) for supporting the JUnit crowdfunding campaign! ------------------------------------------------------------------------
1 parent 39e5afd commit 7ee76c2

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

Diff for: sample-project/src/test/java/com/example/HierarchyTestCase.java

+16-12
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,15 @@ public class HierarchyTestCase {
5050
static boolean thirdLevelTest2Invoked;
5151

5252
@BeforeAll
53-
void beforeAll() {
53+
static void beforeAll() {
5454
topLevelBeforeAllInvocationCount++;
55-
System.out.println(getClass().getName() + " beforeAll called");
55+
System.out.println(HierarchyTestCase.class.getName() + " beforeAll called");
5656
}
5757

5858
@AfterAll
59-
void afterAll() {
59+
static void afterAll() {
6060
topLevelAfterAllInvocationCount++;
61-
System.out.println(getClass().getName() + " afterAll called");
61+
System.out.println(HierarchyTestCase.class.getName() + " afterAll called");
6262
}
6363

6464
@BeforeEach
@@ -89,16 +89,18 @@ void topLevelTest2() {
8989
@Name("Second Level Context")
9090
class SecondLevelTestContext {
9191

92-
@BeforeAll
92+
// TODO [#88] @BeforeAll method cannot be used in @Nested class.
93+
// @BeforeAll
9394
void beforeAll() {
9495
secondLevelBeforeAllInvocationCount++;
95-
System.out.println(getClass().getName() + " beforeAll called");
96+
System.out.println(SecondLevelTestContext.class.getName() + " beforeAll called");
9697
}
9798

98-
@AfterAll
99+
// TODO [#88] @AfterAll method cannot be used in @Nested class.
100+
// @AfterAll
99101
void afterAll() {
100102
secondLevelAfterAllInvocationCount++;
101-
System.out.println(getClass().getName() + " afterAll called");
103+
System.out.println(SecondLevelTestContext.class.getName() + " afterAll called");
102104
}
103105

104106
@BeforeEach
@@ -129,16 +131,18 @@ void secondLevelTest2() {
129131
@Name("Third Level Context")
130132
class ThirdLevelTestContext {
131133

132-
@BeforeAll
134+
// TODO [#88] @BeforeAll method cannot be used in @Nested class.
135+
// @BeforeAll
133136
void beforeAll() {
134137
thirdLevelBeforeAllInvocationCount++;
135-
System.out.println(getClass().getName() + " beforeAll called");
138+
System.out.println(ThirdLevelTestContext.class.getName() + " beforeAll called");
136139
}
137140

138-
@AfterAll
141+
// TODO [#88] @AfterAll method cannot be used in @Nested class.
142+
// @AfterAll
139143
void afterAll() {
140144
thirdLevelAfterAllInvocationCount++;
141-
System.out.println(getClass().getName() + " afterAll called");
145+
System.out.println(ThirdLevelTestContext.class.getName() + " afterAll called");
142146
}
143147

144148
@BeforeEach

0 commit comments

Comments
 (0)