diff --git a/.travis.yml b/.travis.yml index 96ea573..001b352 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,7 @@ cache: matrix: fast_finish: true include: - - jdk: openjdk11 + - jdk: oraclejdk8 before_install: - unset _JAVA_OPTIONS diff --git a/pom.xml b/pom.xml index fc5fb76..39709ee 100644 --- a/pom.xml +++ b/pom.xml @@ -17,9 +17,8 @@ UTF-8 - 10 - 10 - 10 + 1.8 + 1.8 1.3.0-RC1 5.3.0-RC1 6.14.3 @@ -40,7 +39,7 @@ org.junit.jupiter - junit-jupiter-api + junit-jupiter-engine ${junit.jupiter.version} test @@ -96,30 +95,18 @@ - - - de.sormuras - junit-platform-maven-plugin - 0.0.8 - - - - launch-junit-platform - - - - - + org.apache.maven.plugins maven-surefire-plugin 2.22.0 - - - default-test - none - - + + + org.apache.maven.surefire + surefire-junit-platform + 2.22.0 + + diff --git a/src/it/basic/pom.xml b/src/it/basic/pom.xml index a586c29..6f1f81a 100644 --- a/src/it/basic/pom.xml +++ b/src/it/basic/pom.xml @@ -9,9 +9,8 @@ UTF-8 - 10 - 10 - 10 + 1.8 + 1.8 @@ -21,34 +20,27 @@ @project.version@ test + + org.junit.jupiter + junit-jupiter-engine + 5.3.0-RC1 + test + - - - de.sormuras - junit-platform-maven-plugin - 0.0.8 - - - - launch-junit-platform - - - - - org.apache.maven.plugins maven-surefire-plugin 2.22.0 - - - default-test - none - - + + + org.apache.maven.surefire + surefire-junit-platform + 2.22.0 + + diff --git a/src/it/basic/src/test/java/JupiterTests.java b/src/it/basic/src/test/java/JupiterTests.java new file mode 100644 index 0000000..aa88da4 --- /dev/null +++ b/src/it/basic/src/test/java/JupiterTests.java @@ -0,0 +1,7 @@ +import org.junit.jupiter.api.Test; + +class JupiterTests { + + @Test + void jupiter() {} +} diff --git a/src/it/basic/src/test/java/BasicTests.java b/src/it/basic/src/test/java/TestNGTests.java similarity index 79% rename from src/it/basic/src/test/java/BasicTests.java rename to src/it/basic/src/test/java/TestNGTests.java index 71f18df..f4897a2 100644 --- a/src/it/basic/src/test/java/BasicTests.java +++ b/src/it/basic/src/test/java/TestNGTests.java @@ -1,6 +1,6 @@ import org.testng.annotations.Test; -public class BasicTests { +public class TestNGTests { @Test public void test1() {} diff --git a/src/it/basic/verify.bsh b/src/it/basic/verify.bsh index da798a5..ce40683 100644 --- a/src/it/basic/verify.bsh +++ b/src/it/basic/verify.bsh @@ -10,32 +10,22 @@ String[] files = new String[] { // compile: main // // compile: test - "target/test-classes/BasicTests.class", - // test: junit-platform - "target/junit-platform/console-launcher.cmd.log", - "target/junit-platform/console-launcher.out.log" + "target/test-classes/JupiterTests.class", + "target/test-classes/TestNGTests.class", + // test: surefire + "target/surefire-reports/JupiterTests.txt", + "target/surefire-reports/TestNGTests.txt" }; String[] emptyFiles = new String[] { - "target/junit-platform/console-launcher.err.log" }; String log = new String(Files.readAllBytes(basedir.toPath().resolve("build.log")), "UTF-8"); String[] snippets = new String[] { - "[INFO] Launching JUnit Platform...", - "[INFO] Test run finished", - "[INFO] [ 2 containers found ]", // 1 engine + 1 class - "[INFO] [ 0 containers skipped ]", - "[INFO] [ 2 containers started ]", - "[INFO] [ 0 containers aborted ]", - "[INFO] [ 2 containers successful ]", - "[INFO] [ 0 containers failed ]", - "[INFO] [ 2 tests found ]", // 2 methods - "[INFO] [ 0 tests skipped ]", - "[INFO] [ 2 tests started ]", - "[INFO] [ 0 tests aborted ]", - "[INFO] [ 2 tests successful ]", - "[INFO] [ 0 tests failed ]", + "[DEBUG] Using configured provider org.apache.maven.surefire.junitplatform.JUnitPlatformProvider", + "[INFO] Running TestNGTests", + "[INFO] Running JupiterTests", + "[INFO] Tests run: 3, Failures: 0, Errors: 0, Skipped: 0", "[INFO] BUILD SUCCESS" }; diff --git a/src/main/java/org/testng/junit5/NGClassDescriptor.java b/src/main/java/org/testng/junit5/NGClassDescriptor.java index 50d2463..e2dc72b 100644 --- a/src/main/java/org/testng/junit5/NGClassDescriptor.java +++ b/src/main/java/org/testng/junit5/NGClassDescriptor.java @@ -25,7 +25,7 @@ static boolean isCandidate(Class candidate) { } static NGClassDescriptor newContainerDescriptor(UniqueId container, Class candidate) { - var id = container.append("testng-class", candidate.getTypeName()); + UniqueId id = container.append("testng-class", candidate.getTypeName()); return new NGClassDescriptor(id, candidate.getSimpleName(), ClassSource.from(candidate)); } diff --git a/src/main/java/org/testng/junit5/NGMethodDescriptor.java b/src/main/java/org/testng/junit5/NGMethodDescriptor.java index b4814f5..380dfb9 100644 --- a/src/main/java/org/testng/junit5/NGMethodDescriptor.java +++ b/src/main/java/org/testng/junit5/NGMethodDescriptor.java @@ -8,7 +8,7 @@ public class NGMethodDescriptor extends AbstractTestDescriptor { static NGMethodDescriptor newMethodDescriptor(UniqueId container, Method method) { - var id = container.append("testng-method", method.getName()); + UniqueId id = container.append("testng-method", method.getName()); return new NGMethodDescriptor(id, method); } diff --git a/src/main/java/org/testng/junit5/TestNGine.java b/src/main/java/org/testng/junit5/TestNGine.java index f27cea2..64bdabd 100644 --- a/src/main/java/org/testng/junit5/TestNGine.java +++ b/src/main/java/org/testng/junit5/TestNGine.java @@ -6,6 +6,7 @@ import java.util.Optional; import org.junit.platform.commons.util.ClassFilter; import org.junit.platform.engine.EngineDiscoveryRequest; +import org.junit.platform.engine.EngineExecutionListener; import org.junit.platform.engine.ExecutionRequest; import org.junit.platform.engine.TestDescriptor; import org.junit.platform.engine.TestEngine; @@ -25,19 +26,21 @@ public String getId() { } public TestDescriptor discover(EngineDiscoveryRequest request, UniqueId uniqueId) { - var engine = new EngineDescriptor(uniqueId, ENGINE_DISPLAY_NAME); + EngineDescriptor engine = new EngineDescriptor(uniqueId, ENGINE_DISPLAY_NAME); // inspect "request" selectors and filters passed by the user // find TestNG-based test containers (classes) and tests (methods) // wrap each in a new TestDescriptor // add the created descriptor in a tree, below the "engine" descriptor - var filter = ClassFilter.of(buildClassNamePredicate(request), NGClassDescriptor::isCandidate); - var helper = new DiscoveryHelper(request, filter); + ClassFilter filter = + ClassFilter.of(buildClassNamePredicate(request), NGClassDescriptor::isCandidate); + DiscoveryHelper helper = new DiscoveryHelper(request, filter); helper.discover(engine, this::handle); return engine; } private void handle(EngineDescriptor engine, Class candidate) { - var container = NGClassDescriptor.newContainerDescriptor(engine.getUniqueId(), candidate); + NGClassDescriptor container = + NGClassDescriptor.newContainerDescriptor(engine.getUniqueId(), candidate); Arrays.stream(candidate.getMethods()) .filter(method -> method.isAnnotationPresent(Test.class)) .map(method -> NGMethodDescriptor.newMethodDescriptor(container.getUniqueId(), method)) @@ -49,18 +52,18 @@ private void handle(EngineDescriptor engine, Class candidate) { } public void execute(ExecutionRequest request) { - var engine = request.getRootTestDescriptor(); - var listener = request.getEngineExecutionListener(); + TestDescriptor engine = request.getRootTestDescriptor(); + EngineExecutionListener listener = request.getEngineExecutionListener(); listener.executionStarted(engine); // iterate engine.getChildren() recursively and process each via: // 1. tell the listener we started // 2. try to execute the container/test and evaluate its result // 3. tell the listener about the test execution result - for (var classDescriptor : engine.getChildren()) { + for (TestDescriptor classDescriptor : engine.getChildren()) { listener.executionStarted(classDescriptor); - for (var methodDescriptor : classDescriptor.getChildren()) { + for (TestDescriptor methodDescriptor : classDescriptor.getChildren()) { listener.executionStarted(methodDescriptor); - var result = executeMethod((NGMethodDescriptor) methodDescriptor); + TestExecutionResult result = executeMethod((NGMethodDescriptor) methodDescriptor); listener.executionFinished(methodDescriptor, result); } listener.executionFinished(classDescriptor, TestExecutionResult.successful()); @@ -70,7 +73,7 @@ public void execute(ExecutionRequest request) { private TestExecutionResult executeMethod(NGMethodDescriptor descriptor) { try { - var target = descriptor.getMethod().getDeclaringClass().getConstructor().newInstance(); + Object target = descriptor.getMethod().getDeclaringClass().getConstructor().newInstance(); descriptor.getMethod().invoke(target); } catch (ReflectiveOperationException e) { return TestExecutionResult.failed(e);