From d74ee9d8199659a93dbeb2db9f362b172752824c Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Sun, 7 Apr 2024 14:23:35 -0700 Subject: [PATCH] Added supprot for TestNG 7.10.0 --- README.md | 3 +- examples/lib/bld/bld-wrapper.properties | 2 +- .../bld/java/com/example/ExamplesBuild.java | 3 +- .../bld/extension/TestNgOperationBuild.java | 4 +- .../rife/bld/extension/TestNgOperation.java | 38 ++++++++++++++++++- .../bld/extension/TestNgOperationTest.java | 2 +- 6 files changed, 44 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 66fd65a..12750a1 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,5 @@ Don't forget to add a TestNG `test` dependency to your build file, as it is not ```java repositories = List.of(MAVEN_CENTRAL); -scope(test).include(dependency("org.testng", "testng", version(7, 9, 0))); - +scope(test).include(dependency("org.testng", "testng", version(7, 10, 0))); ``` diff --git a/examples/lib/bld/bld-wrapper.properties b/examples/lib/bld/bld-wrapper.properties index 281f0e5..3e2cccf 100644 --- a/examples/lib/bld/bld-wrapper.properties +++ b/examples/lib/bld/bld-wrapper.properties @@ -1,6 +1,6 @@ bld.downloadExtensionJavadoc=false bld.downloadExtensionSources=true -bld.extensions=com.uwyn.rife2:bld-testng:0.9.6-SNAPSHOT +bld.extensions=com.uwyn.rife2:bld-testng:0.9.6 bld.extension.jacoco=com.uwyn.rife2:bld-jacoco-report:0.9.5 bld.repositories=MAVEN_LOCAL,MAVEN_CENTRAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES bld.downloadLocation= diff --git a/examples/src/bld/java/com/example/ExamplesBuild.java b/examples/src/bld/java/com/example/ExamplesBuild.java index dd67bf7..265b245 100644 --- a/examples/src/bld/java/com/example/ExamplesBuild.java +++ b/examples/src/bld/java/com/example/ExamplesBuild.java @@ -30,12 +30,13 @@ public ExamplesBuild() { version = version(0, 1, 0); javaRelease = 17; + downloadSources = true; autoDownloadPurge = true; repositories = List.of(MAVEN_CENTRAL); - scope(test).include(dependency("org.testng", "testng", version(7, 9, 0))); + scope(test).include(dependency("org.testng", "testng", version(7, 10, 0))); } public static void main(String[] args) { diff --git a/src/bld/java/rife/bld/extension/TestNgOperationBuild.java b/src/bld/java/rife/bld/extension/TestNgOperationBuild.java index e4c3235..a452d9c 100644 --- a/src/bld/java/rife/bld/extension/TestNgOperationBuild.java +++ b/src/bld/java/rife/bld/extension/TestNgOperationBuild.java @@ -34,7 +34,7 @@ public class TestNgOperationBuild extends Project { public TestNgOperationBuild() { pkg = "rife.bld.extension"; name = "bld-testng"; - version = version(0, 9, 6, "SNAPSHOT"); + version = version(0, 9, 6); javaRelease = 17; downloadSources = true; @@ -47,7 +47,7 @@ public TestNgOperationBuild() { .include(dependency("com.uwyn.rife2", "bld", version(1, 9, 0))); scope(test) - .include(dependency("org.testng", "testng", version(7, 9, 0))) + .include(dependency("org.testng", "testng", version(7, 10, 0))) .include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 10, 2))) .include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 10, 2))) .include(dependency("org.assertj", "assertj-core", version(3, 25, 3))); diff --git a/src/main/java/rife/bld/extension/TestNgOperation.java b/src/main/java/rife/bld/extension/TestNgOperation.java index f8bb7db..d72a48c 100644 --- a/src/main/java/rife/bld/extension/TestNgOperation.java +++ b/src/main/java/rife/bld/extension/TestNgOperation.java @@ -232,7 +232,8 @@ public TestNgOperation failurePolicy(FailurePolicy policy) { } /** - * Should TestNG consider failures in Data Providers as test failures. + * Should TestNG generate results on a per suite basis by creating a sub directory for each suite and dumping + * results into it. * *

Default is {@code false}

. * @@ -345,6 +346,29 @@ public TestNgOperation listener(Collection listener) { return this; } + /** + * An implementation of {@code ListenerComparator} that will be used by TestNG to determine order of execution for + * listeners. + * + * @param listenerComparator the listener comparator + * @return this operation instance + */ + public TestNgOperation listenerComparator(String listenerComparator) { + options.put("-listenercomparator", listenerComparator); + return this; + } + + /** + * The factory used to create TestNG listeners. + * + * @param listenerFactory the listener factory + * @return this operation instance + */ + public TestNgOperation listenerFactory(String listenerFactory) { + options.put("-listenerfactory", listenerFactory); + return this; + } + /** * Set the Level of verbosity. * @@ -429,6 +453,18 @@ public TestNgOperation mixed(Boolean isMixed) { return this; } + /** + * Fully qualified class name that implements {@code org.testng.ITestObjectFactory} which can be used to create + * test class and listener instances. + * + * @param objectFactory the object factory + * @return this operation instance + */ + public TestNgOperation objectFactory(String objectFactory) { + options.put("-objectfactory", objectFactory); + return this; + } + /** * The list of {@code .class} files or class names implementing {@code ITestRunnerFactory}. * diff --git a/src/test/java/rife/bld/extension/TestNgOperationTest.java b/src/test/java/rife/bld/extension/TestNgOperationTest.java index 3bdc424..f216e13 100644 --- a/src/test/java/rife/bld/extension/TestNgOperationTest.java +++ b/src/test/java/rife/bld/extension/TestNgOperationTest.java @@ -17,7 +17,7 @@ package rife.bld.extension; import org.junit.jupiter.api.Test; -import rife.bld.Project; // NOPMD +import rife.bld.Project; import rife.bld.operations.exceptions.ExitStatusException; import java.util.List;