Skip to content

Commit 04876cf

Browse files
authored
[JAVA-40886] Fix missing tests from junit-5-advanced and junit-5-advanced-2 (#18273)
1 parent 7e1a461 commit 04876cf

File tree

4 files changed

+11
-50
lines changed

4 files changed

+11
-50
lines changed

testing-modules/junit-5-advanced-2/pom.xml

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -27,30 +27,6 @@
2727
<version>${assertj.version}</version>
2828
<scope>test</scope>
2929
</dependency>
30-
<dependency>
31-
<groupId>org.junit.platform</groupId>
32-
<artifactId>junit-platform-suite</artifactId>
33-
<version>${junit-platform.version}</version>
34-
<scope>test</scope>
35-
</dependency>
36-
<dependency>
37-
<groupId>org.junit.platform</groupId>
38-
<artifactId>junit-platform-runner</artifactId>
39-
<version>${junit-platform.version}</version>
40-
<scope>test</scope>
41-
</dependency>
42-
<dependency>
43-
<groupId>org.junit.platform</groupId>
44-
<artifactId>junit-platform-launcher</artifactId>
45-
<version>${junit-platform.version}</version>
46-
<scope>test</scope>
47-
</dependency>
48-
<dependency>
49-
<groupId>org.junit.platform</groupId>
50-
<artifactId>junit-platform-commons</artifactId>
51-
<version>${junit-platform.version}</version>
52-
<scope>test</scope>
53-
</dependency>
5430
<dependency>
5531
<groupId>com.github.stefanbirkner</groupId>
5632
<artifactId>system-lambda</artifactId>

testing-modules/junit-5-advanced-2/src/test/java/com/baeldung/systemexit/TaskServiceSecurityManagerUnitTest.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import java.security.Permission;
77

8+
import org.junit.jupiter.api.AfterEach;
89
import org.junit.jupiter.api.Assertions;
910
import org.junit.jupiter.api.BeforeEach;
1011
import org.junit.jupiter.api.Test;
@@ -16,6 +17,11 @@ void setUp() {
1617
System.setSecurityManager(new NoExitSecurityManager());
1718
}
1819

20+
@AfterEach
21+
void tearDown() {
22+
System.setSecurityManager(null);
23+
}
24+
1925
@Test
2026
void givenDAOThrowsException_whenSaveTaskIsCalled_thenSystemExitIsCalled() throws Exception {
2127
Task task = new Task("test");
@@ -36,7 +42,6 @@ public void checkPermission(Permission perm) {
3642

3743
@Override
3844
public void checkExit(int status) {
39-
super.checkExit(status);
4045
throw new RuntimeException(String.valueOf(status));
4146
}
4247
}

testing-modules/junit-5-advanced/pom.xml

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,6 @@
3333
<version>${junit-platform.version}</version>
3434
<scope>test</scope>
3535
</dependency>
36-
<dependency>
37-
<groupId>org.junit.platform</groupId>
38-
<artifactId>junit-platform-runner</artifactId>
39-
<version>${junit-platform.version}</version>
40-
<scope>test</scope>
41-
</dependency>
42-
<dependency>
43-
<groupId>org.junit.platform</groupId>
44-
<artifactId>junit-platform-commons</artifactId>
45-
<version>${junit-platform.version}</version>
46-
<scope>test</scope>
47-
</dependency>
4836
</dependencies>
4937

5038
<build>
@@ -53,23 +41,13 @@
5341
<groupId>org.apache.maven.plugins</groupId>
5442
<artifactId>maven-surefire-plugin</artifactId>
5543
<version>${maven-surefire-plugin.version}</version>
56-
<configuration>
57-
<argLine>
58-
-javaagent:${settings.localRepository}/org/jmockit/jmockit/${jmockit.version}/jmockit-${jmockit.version}.jar
59-
-Djava.security.manager=allow
60-
</argLine>
61-
<disableXmlReport>true</disableXmlReport>
62-
<excludes>
63-
<exclude>**/testsuite/**/*UnitTest.java</exclude>
64-
</excludes>
65-
</configuration>
6644
</plugin>
6745
</plugins>
6846
</build>
6947

7048
<properties>
7149
<jmockit.version>1.49</jmockit.version>
72-
<junit-platform.version>1.10.1</junit-platform.version>
50+
<junit-platform.version>1.11.0</junit-platform.version>
7351
</properties>
7452

7553
</project>

testing-modules/junit-5-advanced/src/test/java/com/baeldung/testsuite/suites/JUnitRunWithSuite.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22

33
import com.baeldung.testsuite.ClassOneUnitTest;
44
import com.baeldung.testsuite.subpackage.ClassTwoUnitTest;
5-
import org.junit.platform.runner.JUnitPlatform;
65
import org.junit.platform.suite.api.SelectClasses;
6+
import org.junit.platform.suite.api.Suite;
77
import org.junit.platform.suite.api.SuiteDisplayName;
8+
//import org.junit.platform.runner.JUnitPlatform;
89
import org.junit.runner.RunWith;
910

10-
@RunWith(JUnitPlatform.class)
11+
//@RunWith(JUnitPlatform.class) Add junit-platform-runner dependency
12+
@Suite
1113
@SuiteDisplayName("My Test Suite")
1214
@SelectClasses({ClassOneUnitTest.class, ClassTwoUnitTest.class})
1315
public class JUnitRunWithSuite {

0 commit comments

Comments
 (0)