File tree Expand file tree Collapse file tree 4 files changed +11
-50
lines changed
src/test/java/com/baeldung/systemexit
src/test/java/com/baeldung/testsuite/suites Expand file tree Collapse file tree 4 files changed +11
-50
lines changed Original file line number Diff line number Diff line change 27
27
<version >${assertj.version} </version >
28
28
<scope >test</scope >
29
29
</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 >
54
30
<dependency >
55
31
<groupId >com.github.stefanbirkner</groupId >
56
32
<artifactId >system-lambda</artifactId >
Original file line number Diff line number Diff line change 5
5
6
6
import java .security .Permission ;
7
7
8
+ import org .junit .jupiter .api .AfterEach ;
8
9
import org .junit .jupiter .api .Assertions ;
9
10
import org .junit .jupiter .api .BeforeEach ;
10
11
import org .junit .jupiter .api .Test ;
@@ -16,6 +17,11 @@ void setUp() {
16
17
System .setSecurityManager (new NoExitSecurityManager ());
17
18
}
18
19
20
+ @ AfterEach
21
+ void tearDown () {
22
+ System .setSecurityManager (null );
23
+ }
24
+
19
25
@ Test
20
26
void givenDAOThrowsException_whenSaveTaskIsCalled_thenSystemExitIsCalled () throws Exception {
21
27
Task task = new Task ("test" );
@@ -36,7 +42,6 @@ public void checkPermission(Permission perm) {
36
42
37
43
@ Override
38
44
public void checkExit (int status ) {
39
- super .checkExit (status );
40
45
throw new RuntimeException (String .valueOf (status ));
41
46
}
42
47
}
Original file line number Diff line number Diff line change 33
33
<version >${junit-platform.version} </version >
34
34
<scope >test</scope >
35
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-commons</artifactId >
45
- <version >${junit-platform.version} </version >
46
- <scope >test</scope >
47
- </dependency >
48
36
</dependencies >
49
37
50
38
<build >
53
41
<groupId >org.apache.maven.plugins</groupId >
54
42
<artifactId >maven-surefire-plugin</artifactId >
55
43
<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 >
66
44
</plugin >
67
45
</plugins >
68
46
</build >
69
47
70
48
<properties >
71
49
<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>
73
51
</properties >
74
52
75
53
</project >
Original file line number Diff line number Diff line change 2
2
3
3
import com .baeldung .testsuite .ClassOneUnitTest ;
4
4
import com .baeldung .testsuite .subpackage .ClassTwoUnitTest ;
5
- import org .junit .platform .runner .JUnitPlatform ;
6
5
import org .junit .platform .suite .api .SelectClasses ;
6
+ import org .junit .platform .suite .api .Suite ;
7
7
import org .junit .platform .suite .api .SuiteDisplayName ;
8
+ //import org.junit.platform.runner.JUnitPlatform;
8
9
import org .junit .runner .RunWith ;
9
10
10
- @ RunWith (JUnitPlatform .class )
11
+ //@RunWith(JUnitPlatform.class) Add junit-platform-runner dependency
12
+ @ Suite
11
13
@ SuiteDisplayName ("My Test Suite" )
12
14
@ SelectClasses ({ClassOneUnitTest .class , ClassTwoUnitTest .class })
13
15
public class JUnitRunWithSuite {
You can’t perform that action at this time.
0 commit comments