22
22
import org .junit .jupiter .params .provider .Arguments ;
23
23
import org .junit .jupiter .params .provider .EmptySource ;
24
24
import org .junit .jupiter .params .provider .MethodSource ;
25
- import org .junit .platform .console .tasks .ConsoleTestExecutor ;
26
25
27
26
/**
28
27
* @since 1.0
@@ -36,8 +35,7 @@ class ConsoleLauncherTests {
36
35
@ EmptySource
37
36
@ MethodSource ("commandsWithEmptyOptionExitCodes" )
38
37
void displayHelp (String command ) {
39
- var consoleLauncher = new ConsoleLauncher (ConsoleTestExecutor ::new , printSink , printSink );
40
- var exitCode = consoleLauncher .run (command , "--help" ).getExitCode ();
38
+ var exitCode = ConsoleLauncher .run (printSink , printSink , command , "--help" ).getExitCode ();
41
39
42
40
assertEquals (0 , exitCode );
43
41
assertThat (output ()).contains ("--help" );
@@ -47,8 +45,7 @@ void displayHelp(String command) {
47
45
@ EmptySource
48
46
@ MethodSource ("commandsWithEmptyOptionExitCodes" )
49
47
void displayVersion (String command ) {
50
- var consoleLauncher = new ConsoleLauncher (ConsoleTestExecutor ::new , printSink , printSink );
51
- var exitCode = consoleLauncher .run (command , "--version" ).getExitCode ();
48
+ var exitCode = ConsoleLauncher .run (printSink , printSink , command , "--version" ).getExitCode ();
52
49
53
50
assertEquals (0 , exitCode );
54
51
assertThat (output ()).contains ("JUnit Platform Console Launcher" );
@@ -57,17 +54,15 @@ void displayVersion(String command) {
57
54
@ ParameterizedTest (name = "{0}" )
58
55
@ MethodSource ("commandsWithEmptyOptionExitCodes" )
59
56
void displayBanner (String command ) {
60
- var consoleLauncher = new ConsoleLauncher (ConsoleTestExecutor ::new , printSink , printSink );
61
- consoleLauncher .run (command );
57
+ ConsoleLauncher .run (printSink , printSink , command );
62
58
63
59
assertThat (output ()).contains ("Thanks for using JUnit!" );
64
60
}
65
61
66
62
@ ParameterizedTest (name = "{0}" )
67
63
@ MethodSource ("commandsWithEmptyOptionExitCodes" )
68
64
void disableBanner (String command , int expectedExitCode ) {
69
- var consoleLauncher = new ConsoleLauncher (ConsoleTestExecutor ::new , printSink , printSink );
70
- var exitCode = consoleLauncher .run (command , "--disable-banner" ).getExitCode ();
65
+ var exitCode = ConsoleLauncher .run (printSink , printSink , command , "--disable-banner" ).getExitCode ();
71
66
72
67
assertEquals (expectedExitCode , exitCode );
73
68
assertThat (output ()).doesNotContain ("Thanks for using JUnit!" );
@@ -76,8 +71,7 @@ void disableBanner(String command, int expectedExitCode) {
76
71
@ ParameterizedTest (name = "{0}" )
77
72
@ MethodSource ("commandsWithEmptyOptionExitCodes" )
78
73
void executeWithUnknownCommandLineOption (String command ) {
79
- var consoleLauncher = new ConsoleLauncher (ConsoleTestExecutor ::new , printSink , printSink );
80
- var exitCode = consoleLauncher .run (command , "--all" ).getExitCode ();
74
+ var exitCode = ConsoleLauncher .run (printSink , printSink , command , "--all" ).getExitCode ();
81
75
82
76
assertEquals (-1 , exitCode );
83
77
assertThat (output ()).contains ("Unknown option: '--all'" ).contains ("Usage:" );
@@ -90,8 +84,7 @@ private String output() {
90
84
@ ParameterizedTest (name = "{0}" )
91
85
@ MethodSource ("commandsWithEmptyOptionExitCodes" )
92
86
void executeWithoutCommandLineOptions (String command , int expectedExitCode ) {
93
- var consoleLauncher = new ConsoleLauncher (ConsoleTestExecutor ::new , printSink , printSink );
94
- var actualExitCode = consoleLauncher .run (command ).getExitCode ();
87
+ var actualExitCode = ConsoleLauncher .run (printSink , printSink , command ).getExitCode ();
95
88
96
89
assertEquals (expectedExitCode , actualExitCode );
97
90
}
0 commit comments