1414import static org .junit .jupiter .api .Assertions .assertLinesMatch ;
1515import static org .junit .jupiter .api .Assertions .assertTrue ;
1616
17+ import java .io .File ;
1718import java .io .IOException ;
1819import java .nio .file .Files ;
1920import java .nio .file .Path ;
21+ import java .util .ArrayList ;
2022
23+ import de .sormuras .bartholdy .jdk .Jar ;
2124import de .sormuras .bartholdy .jdk .Javac ;
2225import de .sormuras .bartholdy .tool .Java ;
2326
27+ import org .junit .jupiter .api .Disabled ;
2428import org .junit .jupiter .api .MethodOrderer ;
2529import org .junit .jupiter .api .Order ;
2630import org .junit .jupiter .api .Test ;
@@ -37,7 +41,7 @@ class StandaloneTests {
3741
3842 @ Test
3943 @ Order (1 )
40- void compile () {
44+ void compile () throws Exception {
4145 var workspace = Request .WORKSPACE .resolve ("standalone" );
4246 var result = Request .builder () //
4347 .setTool (new Javac ()) //
@@ -52,6 +56,17 @@ void compile() {
5256 assertEquals (0 , result .getExitCode (), String .join ("\n " , result .getOutputLines ("out" )));
5357 assertTrue (result .getOutput ("out" ).isEmpty ());
5458 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" )));
5570 }
5671
5772 @ Test
@@ -87,4 +102,32 @@ void test() throws IOException {
87102 assertTrue (result .getOutput ("err" ).contains ("junit-vintage"
88103 + " (group ID: org.junit.vintage, artifact ID: junit-vintage-engine, version: " + vintageVersion ));
89104 }
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+ }
90133}
0 commit comments