Skip to content

Commit

Permalink
Add test for jarred test classes not being found
Browse files Browse the repository at this point in the history
  • Loading branch information
sormuras committed Jun 30, 2019
1 parent 68c3445 commit a02aa04
Showing 1 changed file with 44 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,17 @@
import static org.junit.jupiter.api.Assertions.assertLinesMatch;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;

import de.sormuras.bartholdy.jdk.Jar;
import de.sormuras.bartholdy.jdk.Javac;
import de.sormuras.bartholdy.tool.Java;

import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
Expand All @@ -37,7 +41,7 @@ class StandaloneTests {

@Test
@Order(1)
void compile() {
void compile() throws Exception {
var workspace = Request.WORKSPACE.resolve("standalone");
var result = Request.builder() //
.setTool(new Javac()) //
Expand All @@ -52,6 +56,17 @@ void compile() {
assertEquals(0, result.getExitCode(), String.join("\n", result.getOutputLines("out")));
assertTrue(result.getOutput("out").isEmpty());
assertTrue(result.getOutput("err").isEmpty());

// create "tests.jar" that'll be picked-up by "testWithJarredTestClasses()" later
var jarFolder = Files.createDirectories(workspace.resolve("jar"));
var jarResult = Request.builder() //
.setTool(new Jar()) //
.setProject("standalone") //
.addArguments("--create") //
.addArguments("--file", jarFolder.resolve("tests.jar")) //
.addArguments("-C", workspace.resolve("bin"), ".") //
.build().run(false);
assertEquals(0, jarResult.getExitCode(), String.join("\n", jarResult.getOutputLines("out")));
}

@Test
Expand Down Expand Up @@ -87,4 +102,32 @@ void test() throws IOException {
assertTrue(result.getOutput("err").contains("junit-vintage"
+ " (group ID: org.junit.vintage, artifact ID: junit-vintage-engine, version: " + vintageVersion));
}

@Test
@Order(3)
@Disabled("https://github.com/junit-team/junit5/issues/1724")
void testWithJarredTestClasses() {
var root = Path.of("../../..");
var jar = root.resolve(Helper.createJarPath("junit-platform-console-standalone"));
var path = new ArrayList<String>();
// path.add("bin"); // "exploded" test classes are found, see also test() above
path.add(Request.WORKSPACE.resolve("standalone/jar/tests.jar").toString());
path.add(jar.toString());
var result = Request.builder() //
.setTool(new Java()) //
.setProject("standalone") //
.addArguments("--show-version") //
.addArguments("-enableassertions") //
.addArguments("-Djava.util.logging.config.file=logging.properties") //
.addArguments("--class-path", String.join(File.pathSeparator, path)) //
.addArguments("org.junit.platform.console.ConsoleLauncher") //
.addArguments("--scan-class-path") //
.addArguments("--disable-banner") //
.addArguments("--include-classname", "standalone.*") //
.addArguments("--fail-if-no-tests") //
.build() //
.run(false);

assertEquals(1, result.getExitCode(), String.join("\n", result.getOutputLines("out")));
}
}

0 comments on commit a02aa04

Please sign in to comment.