14
14
import static org .junit .jupiter .api .Assertions .assertLinesMatch ;
15
15
import static org .junit .jupiter .api .Assertions .assertTrue ;
16
16
17
+ import java .io .File ;
17
18
import java .io .IOException ;
18
19
import java .nio .file .Files ;
19
20
import java .nio .file .Path ;
21
+ import java .util .ArrayList ;
20
22
23
+ import de .sormuras .bartholdy .jdk .Jar ;
21
24
import de .sormuras .bartholdy .jdk .Javac ;
22
25
import de .sormuras .bartholdy .tool .Java ;
23
26
27
+ import org .junit .jupiter .api .Disabled ;
24
28
import org .junit .jupiter .api .MethodOrderer ;
25
29
import org .junit .jupiter .api .Order ;
26
30
import org .junit .jupiter .api .Test ;
@@ -37,7 +41,7 @@ class StandaloneTests {
37
41
38
42
@ Test
39
43
@ Order (1 )
40
- void compile () {
44
+ void compile () throws Exception {
41
45
var workspace = Request .WORKSPACE .resolve ("standalone" );
42
46
var result = Request .builder () //
43
47
.setTool (new Javac ()) //
@@ -52,6 +56,17 @@ void compile() {
52
56
assertEquals (0 , result .getExitCode (), String .join ("\n " , result .getOutputLines ("out" )));
53
57
assertTrue (result .getOutput ("out" ).isEmpty ());
54
58
assertTrue (result .getOutput ("err" ).isEmpty ());
59
+
60
+ // create "tests.jar" that'll be picked-up by "testWithJarredTestClasses()" later
61
+ var jarFolder = Files .createDirectories (workspace .resolve ("jar" ));
62
+ var jarResult = Request .builder () //
63
+ .setTool (new Jar ()) //
64
+ .setProject ("standalone" ) //
65
+ .addArguments ("--create" ) //
66
+ .addArguments ("--file" , jarFolder .resolve ("tests.jar" )) //
67
+ .addArguments ("-C" , workspace .resolve ("bin" ), "." ) //
68
+ .build ().run (false );
69
+ assertEquals (0 , jarResult .getExitCode (), String .join ("\n " , jarResult .getOutputLines ("out" )));
55
70
}
56
71
57
72
@ Test
@@ -87,4 +102,32 @@ void test() throws IOException {
87
102
assertTrue (result .getOutput ("err" ).contains ("junit-vintage"
88
103
+ " (group ID: org.junit.vintage, artifact ID: junit-vintage-engine, version: " + vintageVersion ));
89
104
}
105
+
106
+ @ Test
107
+ @ Order (3 )
108
+ @ Disabled ("https://github.com/junit-team/junit5/issues/1724" )
109
+ void testWithJarredTestClasses () {
110
+ var root = Path .of ("../../.." );
111
+ var jar = root .resolve (Helper .createJarPath ("junit-platform-console-standalone" ));
112
+ var path = new ArrayList <String >();
113
+ // path.add("bin"); // "exploded" test classes are found, see also test() above
114
+ path .add (Request .WORKSPACE .resolve ("standalone/jar/tests.jar" ).toString ());
115
+ path .add (jar .toString ());
116
+ var result = Request .builder () //
117
+ .setTool (new Java ()) //
118
+ .setProject ("standalone" ) //
119
+ .addArguments ("--show-version" ) //
120
+ .addArguments ("-enableassertions" ) //
121
+ .addArguments ("-Djava.util.logging.config.file=logging.properties" ) //
122
+ .addArguments ("--class-path" , String .join (File .pathSeparator , path )) //
123
+ .addArguments ("org.junit.platform.console.ConsoleLauncher" ) //
124
+ .addArguments ("--scan-class-path" ) //
125
+ .addArguments ("--disable-banner" ) //
126
+ .addArguments ("--include-classname" , "standalone.*" ) //
127
+ .addArguments ("--fail-if-no-tests" ) //
128
+ .build () //
129
+ .run (false );
130
+
131
+ assertEquals (1 , result .getExitCode (), String .join ("\n " , result .getOutputLines ("out" )));
132
+ }
90
133
}
0 commit comments