* @return this operation instance
*/
public TestNgOperation mixed(Boolean isMixed) {
- options_.put("-mixed", String.valueOf(isMixed));
+ options.put("-mixed", String.valueOf(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}.
- *
- * A fully qualified class name that implements {@code org.testng.ITestObjectFactory} which can be used to create
- * test class and listener instances.
*
- * @param factory one or more factory
+ * @param factory one or more factories
* @return this operation instance
* @see #objectFactory(Collection) #objectFactory(Collection)
*/
public TestNgOperation objectFactory(String... factory) {
- return objectFactory(List.of(factory));
+ options.put("-objectfactory", String.join(",", Arrays.stream(factory).filter(this::isNotBlank).toList()));
+ return this;
}
/**
* The list of {@code .class} files or class names implementing {@code ITestRunnerFactory}.
- *
- * A fully qualified class name that implements {@code org.testng.ITestObjectFactory} which can be used to create
- * test class and listener instances.
*
* @param factory the list of factories
* @return this operation instance
* @see #objectFactory(String...) #objectFactory(String...)
*/
public TestNgOperation objectFactory(Collection factory) {
- options_.put("-objectfactory", String.join(",", factory.stream().filter(this::isNotBlank).toList()));
+ options.put("-objectfactory", String.join(",", factory.stream().filter(this::isNotBlank).toList()));
return this;
}
- /**
- * Returns the run options.
- *
- * @return the map of run options
- */
- public Map options() {
- return options_;
- }
-
/**
* The list of fully qualified class names of listeners that should be skipped from being wired in via
* Service Loaders.
@@ -580,7 +498,9 @@ public class TestNgOperation extends TestOperation
* @see #overrideIncludedMethods(Collection) #overrideIncludedMethods(Collection)
*/
public TestNgOperation overrideIncludedMethods(String... method) {
- return overrideIncludedMethods(List.of(method));
+ options.put("-overrideincludedmethods",
+ String.join(",", Arrays.stream(method).filter(this::isNotBlank).toList()));
+ return this;
}
/**
@@ -592,7 +512,7 @@ public class TestNgOperation extends TestOperation
* @see #overrideIncludedMethods(String...) #overrideIncludedMethods(String...)
*/
public TestNgOperation overrideIncludedMethods(Collection method) {
- options_.put("-overrideincludedmethods", String.join(",", method.stream().filter(this::isNotBlank).toList()));
+ options.put("-overrideincludedmethods", String.join(",", method.stream().filter(this::isNotBlank).toList()));
return this;
}
@@ -608,7 +528,8 @@ public class TestNgOperation extends TestOperation
* @see #packages(Collection) #packages(Collection)
*/
public TestNgOperation packages(String... name) {
- return packages(List.of(name));
+ packages.addAll(Arrays.stream(name).filter(this::isNotBlank).toList());
+ return this;
}
/**
@@ -623,19 +544,10 @@ public class TestNgOperation extends TestOperation
* @see #packages(String...) #packages(String...)
*/
public TestNgOperation packages(Collection name) {
- packages_.addAll(name.stream().filter(this::isNotBlank).toList());
+ packages.addAll(name.stream().filter(this::isNotBlank).toList());
return this;
}
- /**
- * Returns the suite packages to run.
- *
- * @return the set of packages
- */
- public Set packages() {
- return packages_;
- }
-
/**
* If specified, sets the default mechanism used to determine how to use parallel threads when running tests.
* If not set, default mechanism is not to use parallel threads at all.
@@ -646,7 +558,7 @@ public class TestNgOperation extends TestOperation
* @see Parallel
*/
public TestNgOperation parallel(Parallel mechanism) {
- options_.put("-parallel", mechanism.name().toLowerCase(Locale.getDefault()));
+ options.put("-parallel", mechanism.name().toLowerCase(Locale.getDefault()));
return this;
}
@@ -658,7 +570,7 @@ public class TestNgOperation extends TestOperation
*/
public TestNgOperation port(int port) {
if (port >= 1) {
- options_.put("-port", String.valueOf(port));
+ options.put("-port", String.valueOf(port));
}
return this;
}
@@ -672,7 +584,7 @@ public class TestNgOperation extends TestOperation
* @return this operation instance
*/
public TestNgOperation propagateDataProviderFailureAsTestFailure(Boolean isPropagateDataProviderFailure) {
- options_.put("-propagateDataProviderFailureAsTestFailure", String.valueOf(isPropagateDataProviderFailure));
+ options.put("-propagateDataProviderFailureAsTestFailure", String.valueOf(isPropagateDataProviderFailure));
return this;
}
@@ -684,7 +596,7 @@ public class TestNgOperation extends TestOperation
*/
public TestNgOperation reporter(String reporter) {
if (isNotBlank(reporter)) {
- options_.put("-reporter", reporter);
+ options.put("-reporter", reporter);
}
return this;
}
@@ -697,7 +609,7 @@ public class TestNgOperation extends TestOperation
*/
public TestNgOperation shareThreadPoolForDataProviders(boolean shareThreadPoolForDataProviders) {
if (shareThreadPoolForDataProviders) {
- options_.put("-shareThreadPoolForDataProviders", "true");
+ options.put("-shareThreadPoolForDataProviders", String.valueOf(shareThreadPoolForDataProviders));
}
return this;
}
@@ -709,49 +621,10 @@ public class TestNgOperation extends TestOperation
*
* @param directory one or more directories
* @return this operation instance
- * @see #sourceDir(Collection)
+ * @see #sourceDir(String...) #sourceDir(String...)
*/
public TestNgOperation sourceDir(String... directory) {
- return sourceDir(List.of(directory));
- }
-
- /**
- * The directories where your javadoc annotated test sources are. This option is only necessary
- * if you are using javadoc type annotations. (e.g. {@code "src/test"} or
- * {@code "src/test/org/testng/eclipse-plugin", "src/test/org/testng/testng"}).
- *
- * @param directory one or more directories
- * @return this operation instance
- * @see #sourceDirFiles(Collection)
- */
- public TestNgOperation sourceDir(File... directory) {
- return sourceDirFiles(List.of(directory));
- }
-
- /**
- * The directories where your javadoc annotated test sources are. This option is only necessary
- * if you are using javadoc type annotations. (e.g. {@code "src/test"} or
- * {@code "src/test/org/testng/eclipse-plugin", "src/test/org/testng/testng"}).
- *
- * @param directory one or more directories
- * @return this operation instance
- * @see #sourceDirPaths(Collection)
- */
- public TestNgOperation sourceDir(Path... directory) {
- return sourceDirPaths(List.of(directory));
- }
-
- /**
- * The directories where your javadoc annotated test sources are. This option is only necessary
- * if you are using javadoc type annotations. (e.g. {@code "src/test"} or
- * {@code "src/test/org/testng/eclipse-plugin", "src/test/org/testng/testng"}).
- *
- * @param directory the list of directories
- * @return this operation instance
- * @see #sourceDir(String...)
- */
- public TestNgOperation sourceDir(Collection directory) {
- options_.put("-sourcedir", String.join(";", directory.stream().filter(this::isNotBlank).toList()));
+ options.put("-sourcedir", String.join(";", Arrays.stream(directory).filter(this::isNotBlank).toList()));
return this;
}
@@ -762,23 +635,11 @@ public class TestNgOperation extends TestOperation
*
* @param directory the list of directories
* @return this operation instance
- * @see #sourceDir(File...)
+ * @see #sourceDir(String...) #sourceDir(String...)
*/
- public TestNgOperation sourceDirFiles(Collection directory) {
- return sourceDir(directory.stream().map(File::getAbsolutePath).toList());
- }
-
- /**
- * The directories where your javadoc annotated test sources are. This option is only necessary
- * if you are using javadoc type annotations. (e.g. {@code "src/test"} or
- * {@code "src/test/org/testng/eclipse-plugin", "src/test/org/testng/testng"}).
- *
- * @param directory the list of directories
- * @return this operation instance
- * @see #sourceDir(Path...)
- */
- public TestNgOperation sourceDirPaths(Collection directory) {
- return sourceDirFiles(directory.stream().map(Path::toFile).toList());
+ public TestNgOperation sourceDir(Collection directory) {
+ options.put("-sourcedir", String.join(";", directory.stream().filter(this::isNotBlank).toList()));
+ return this;
}
/**
@@ -790,7 +651,9 @@ public class TestNgOperation extends TestOperation
* @see #spiListenersToSkip(Collection) #spiListenersToSkip(Collection)
*/
public TestNgOperation spiListenersToSkip(String... listenerToSkip) {
- return spiListenersToSkip(List.of(listenerToSkip));
+ options.put("-spilistenerstoskip",
+ String.join(",", Arrays.stream(listenerToSkip).filter(this::isNotBlank).toList()));
+ return this;
}
/**
@@ -802,7 +665,7 @@ public class TestNgOperation extends TestOperation
* @see #spiListenersToSkip(String...) #spiListenersToSkip(String...)
*/
public TestNgOperation spiListenersToSkip(Collection listenerToSkip) {
- options_.put("-spilistenerstoskip",
+ options.put("-spilistenerstoskip",
String.join(",", listenerToSkip.stream().filter(this::isNotBlank).toList()));
return this;
}
@@ -816,7 +679,7 @@ public class TestNgOperation extends TestOperation
*/
public TestNgOperation suiteName(String name) {
if (isNotBlank(name)) {
- options_.put("-suitename", '"' + name + '"');
+ options.put("-suitename", '"' + name + '"');
}
return this;
}
@@ -830,7 +693,7 @@ public class TestNgOperation extends TestOperation
*/
public TestNgOperation suiteThreadPoolSize(int poolSize) {
if (poolSize >= 0) {
- options_.put("-suitethreadpoolsize", String.valueOf(poolSize));
+ options.put("-suitethreadpoolsize", String.valueOf(poolSize));
}
return this;
}
@@ -845,7 +708,8 @@ public class TestNgOperation extends TestOperation
* @see #suites(Collection) #suites(Collection)
*/
public TestNgOperation suites(String... suite) {
- return suites(List.of(suite));
+ suites.addAll(Arrays.stream(suite).filter(this::isNotBlank).toList());
+ return this;
}
/**
@@ -858,19 +722,10 @@ public class TestNgOperation extends TestOperation
* @see #suites(String...) #suites(String...)
*/
public TestNgOperation suites(Collection suite) {
- suites_.addAll(suite.stream().filter(this::isNotBlank).toList());
+ suites.addAll(suite.stream().filter(this::isNotBlank).toList());
return this;
}
- /**
- * Returns the suites to run.
- *
- * @return the set of suites
- */
- public Set suites() {
- return suites_;
- }
-
/**
* Create a test file and delete it on exit.
*
@@ -892,7 +747,8 @@ public class TestNgOperation extends TestOperation
* @see #testClass(Collection) #testClass(Collection)
*/
public TestNgOperation testClass(String... aClass) {
- return testClass(List.of(aClass));
+ options.put("-testclass", String.join(",", Arrays.stream(aClass).filter(this::isNotBlank).toList()));
+ return this;
}
/**
@@ -905,7 +761,7 @@ public class TestNgOperation extends TestOperation
* @see #testClass(String...) #testClass(String...)
*/
public TestNgOperation testClass(Collection aClass) {
- options_.put("-testclass", String.join(",", aClass.stream().filter(this::isNotBlank).toList()));
+ options.put("-testclass", String.join(",", aClass.stream().filter(this::isNotBlank).toList()));
return this;
}
@@ -917,7 +773,8 @@ public class TestNgOperation extends TestOperation
* @see #testClasspath(String...) #testClasspath(String...)
*/
public TestNgOperation testClasspath(String... entry) {
- return testClasspath(List.of(entry));
+ testClasspath.addAll(Arrays.stream(entry).filter(this::isNotBlank).toList());
+ return this;
}
/**
@@ -928,19 +785,10 @@ public class TestNgOperation extends TestOperation
* @see #testClasspath(String...) #testClasspath(String...)
*/
public TestNgOperation testClasspath(Collection entry) {
- testClasspath_.addAll(entry.stream().filter(this::isNotBlank).toList());
+ testClasspath.addAll(entry.stream().filter(this::isNotBlank).toList());
return this;
}
- /**
- * Returns the classpath entries used for running tests.
- *
- * @return the set of test classpath
- */
- public Set testClasspath() {
- return testClasspath_;
- }
-
/**
* Specifies a jar file that contains test classes. If a {@code testng.xml} file is found at the root of that
* jar file, it will be used, otherwise, all the test classes found in this jar file will be considered test
@@ -951,7 +799,7 @@ public class TestNgOperation extends TestOperation
*/
public TestNgOperation testJar(String jar) {
if (isNotBlank(jar)) {
- options_.put("-testjar", jar);
+ options.put("-testjar", jar);
}
return this;
}
@@ -965,7 +813,7 @@ public class TestNgOperation extends TestOperation
*/
public TestNgOperation testName(String name) {
if (isNotBlank(name)) {
- options_.put("-testname", '"' + name + '"');
+ options.put("-testname", '"' + name + '"');
}
return this;
}
@@ -978,7 +826,9 @@ public class TestNgOperation extends TestOperation
* @see #testNames(Collection) #testNames(Collection)
*/
public TestNgOperation testNames(String... name) {
- return testNames(List.of(name));
+ options.put("-testnames",
+ Arrays.stream(name).filter(this::isNotBlank).map(s -> '"' + s + '"').collect(Collectors.joining(",")));
+ return this;
}
/**
@@ -989,7 +839,7 @@ public class TestNgOperation extends TestOperation
* @see #testName(String) #testName(String)
*/
public TestNgOperation testNames(Collection name) {
- options_.put("-testnames",
+ options.put("-testnames",
name.stream().filter(this::isNotBlank).map(s -> '"' + s + '"').collect(Collectors.joining(",")));
return this;
}
@@ -1002,7 +852,7 @@ public class TestNgOperation extends TestOperation
*/
public TestNgOperation testRunFactory(String factory) {
if (isNotBlank(factory)) {
- options_.put("-testrunfactory", factory);
+ options.put("-testrunfactory", factory);
}
return this;
}
@@ -1017,7 +867,7 @@ public class TestNgOperation extends TestOperation
*/
public TestNgOperation threadCount(int count) {
if (count >= 0) {
- options_.put("-threadcount", String.valueOf(count));
+ options.put("-threadcount", String.valueOf(count));
}
return this;
}
@@ -1030,7 +880,7 @@ public class TestNgOperation extends TestOperation
*/
public TestNgOperation threadPoolFactoryClass(String factoryClass) {
if (isNotBlank(factoryClass)) {
- options_.put("-threadpoolfactoryclass", factoryClass);
+ options.put("-threadpoolfactoryclass", factoryClass);
}
return this;
}
@@ -1044,7 +894,7 @@ public class TestNgOperation extends TestOperation
* @return this operation instance
*/
public TestNgOperation useDefaultListeners(Boolean isDefaultListener) {
- options_.put("-usedefaultlisteners", String.valueOf(isDefaultListener));
+ options.put("-usedefaultlisteners", String.valueOf(isDefaultListener));
return this;
}
@@ -1056,7 +906,7 @@ public class TestNgOperation extends TestOperation
*/
public TestNgOperation useGlobalThreadPool(boolean useGlobalThreadPool) {
if (useGlobalThreadPool) {
- options_.put("-useGlobalThreadPool", "true");
+ options.put("-useGlobalThreadPool", String.valueOf(useGlobalThreadPool));
}
return this;
}
@@ -1070,7 +920,7 @@ public class TestNgOperation extends TestOperation
*/
public TestNgOperation verbose(int level) {
if (level >= 0) {
- options_.put("-verbose", String.valueOf(level));
+ options.put("-verbose", String.valueOf(level));
}
return this;
}
@@ -1079,11 +929,11 @@ public class TestNgOperation extends TestOperation
var temp = tempFile();
try (var bufWriter = Files.newBufferedWriter(Paths.get(temp.getPath()))) {
bufWriter.write("" +
- "" +
- "" +
- "" +
- "");
- for (var p : packages_) {
+ "" +
+ "" +
+ "" +
+ "");
+ for (var p : packages) {
bufWriter.write(String.format("", p));
}
bufWriter.write("");
@@ -1101,35 +951,11 @@ public class TestNgOperation extends TestOperation
*/
public TestNgOperation xmlPathInJar(String path) {
if (isNotBlank(path)) {
- options_.put("-xmlpathinjar", path);
+ options.put("-xmlpathinjar", path);
}
return this;
}
- /**
- * This attribute should contain the path to a valid XML file inside the test jar
- * (e.g. {@code "resources/testng.xml"}). The default is {@code testng.xml}, which means a file called
- * {@code testng.xml} at the root of the jar file. This option will be ignored unless a test jar is specified.
- *
- * @param path the path
- * @return this operation instance
- */
- public TestNgOperation xmlPathInJar(File path) {
- return xmlPathInJar(path.getAbsolutePath());
- }
-
- /**
- * This attribute should contain the path to a valid XML file inside the test jar
- * (e.g. {@code "resources/testng.xml"}). The default is {@code testng.xml}, which means a file called
- * {@code testng.xml} at the root of the jar file. This option will be ignored unless a test jar is specified.
- *
- * @param path the path
- * @return this operation instance
- */
- public TestNgOperation xmlPathInJar(Path path) {
- return xmlPathInJar(path.toFile());
- }
-
/**
* Parallel Mechanisms
*/
diff --git a/src/test/java/rife/bld/extension/TestNgExample.java b/src/test/java/rife/bld/extension/TestNgExample.java
index faa223a..c2dc3e0 100644
--- a/src/test/java/rife/bld/extension/TestNgExample.java
+++ b/src/test/java/rife/bld/extension/TestNgExample.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2023-2025 the original author or authors.
+ * Copyright 2023-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,9 +22,8 @@ package rife.bld.extension;
* @author Erik C. Thauvin
* @since 1.0
*/
-@SuppressWarnings({"PMD.TestClassWithoutTestCases", "unused"})
+@SuppressWarnings("PMD.TestClassWithoutTestCases")
class TestNgExample {
- @SuppressWarnings("SameReturnValue")
public String getMessage() {
return "Hello World!";
}
diff --git a/src/test/java/rife/bld/extension/TestNgExampleTest.java b/src/test/java/rife/bld/extension/TestNgExampleTest.java
index 6d3c9b0..a2c35b9 100644
--- a/src/test/java/rife/bld/extension/TestNgExampleTest.java
+++ b/src/test/java/rife/bld/extension/TestNgExampleTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2023-2025 the original author or authors.
+ * Copyright 2023-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,7 +25,6 @@ import org.testng.annotations.Test;
* @author Erik C. Thauvin
* @since 1.0
*/
-@SuppressWarnings("unused")
class TestNgExampleTest {
private final TestNgExample example = new TestNgExample();
diff --git a/src/test/java/rife/bld/extension/TestNgOperationTest.java b/src/test/java/rife/bld/extension/TestNgOperationTest.java
index d4f3193..f216e13 100644
--- a/src/test/java/rife/bld/extension/TestNgOperationTest.java
+++ b/src/test/java/rife/bld/extension/TestNgOperationTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2023-2025 the original author or authors.
+ * Copyright 2023-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,18 +16,10 @@
package rife.bld.extension;
-import org.assertj.core.api.AutoCloseableSoftAssertions;
import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.condition.EnabledOnOs;
-import org.junit.jupiter.api.condition.OS;
import rife.bld.Project;
-import rife.bld.blueprints.BaseProjectBlueprint;
import rife.bld.operations.exceptions.ExitStatusException;
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Paths;
import java.util.List;
import static org.assertj.core.api.Assertions.*;
@@ -46,125 +38,47 @@ class TestNgOperationTest {
@Test
void testAlwaysRunListeners() {
var op = new TestNgOperation().alwaysRunListeners(false);
- assertThat(op.options().get("-alwaysrunlisteners")).isEqualTo("false");
+ assertThat(op.options.get("-alwaysrunlisteners")).isEqualTo("false");
op = new TestNgOperation().alwaysRunListeners(true);
- assertThat(op.options().get("-alwaysrunlisteners")).isEqualTo("true");
- }
-
- @Test
- @EnabledOnOs(OS.LINUX)
- void testCheckAllParameters() throws IOException {
- var args = Files.readAllLines(Paths.get("src", "test", "resources", "testng-args.txt"));
-
- assertThat(args).isNotEmpty();
-
- var params = new TestNgOperation()
- .fromProject(new BaseProjectBlueprint(new File("examples"), "com.example", "examples", "Examples"))
- .alwaysRunListeners(true)
- .dataProviderThreadCount(1)
- .dependencyInjectorFactory("injectorfactory")
- .directory("dir")
- .excludeGroups("group")
- .failWhenEverythingSkipped(true)
- .failurePolicy(TestNgOperation.FailurePolicy.SKIP)
- .generateResultsPerSuite(true)
- .groups("group1", "group2")
- .ignoreMissedTestName(true)
- .includeAllDataDrivenTestsWhenSkipping(true)
- .listener("listener")
- .listenerComparator("comparator")
- .listenerFactory("factory")
- .log(1)
- .methodSelectors("selector")
- .methods("methods")
- .mixed(true)
- .objectFactory("objectFactory")
- .overrideIncludedMethods("method")
- .parallel(TestNgOperation.Parallel.TESTS)
- .propagateDataProviderFailureAsTestFailure(true)
- .reporter("reporter")
- .shareThreadPoolForDataProviders(true)
- .spiListenersToSkip("listenter")
- .suiteName("name")
- .suiteThreadPoolSize(1)
- .testClass("class")
- .testJar("jar")
- .testName("name")
- .testNames("names")
- .testRunFactory("runFactory")
- .threadCount(1)
- .threadPoolFactoryClass("poolClass")
- .useDefaultListeners(true)
- .useGlobalThreadPool(true)
- .verbose(1)
- .xmlPathInJar("jarPath")
- .executeConstructProcessCommandList();
-
- try (var softly = new AutoCloseableSoftAssertions()) {
- for (var p : args) {
- var found = false;
- for (var a : params) {
- if (a.startsWith(p)) {
- found = true;
- break;
- }
- }
- softly.assertThat(found).as(p + " not found.").isTrue();
- }
- }
-
+ assertThat(op.options.get("-alwaysrunlisteners")).isEqualTo("true");
}
@Test
void testClass() {
var op = new TestNgOperation().testClass(FOO, BAR);
- assertThat(op.options().get("-testclass")).isEqualTo(String.format("%s,%s", FOO, BAR));
+ assertThat(op.options.get("-testclass")).isEqualTo(String.format("%s,%s", FOO, BAR));
new TestNgOperation().testClass(List.of(FOO, BAR));
- assertThat(op.options().get("-testclass")).as("as list")
+ assertThat(op.options.get("-testclass")).as("as list")
.isEqualTo(String.format("%s,%s", FOO, BAR));
}
- @Test
- void testClasspath() {
- var op = new TestNgOperation().testClasspath(FOO, BAR);
- assertThat(op.testClasspath()).containsExactly(BAR, FOO);
- }
-
@Test
void testDataProviderThreadCount() {
var op = new TestNgOperation().dataProviderThreadCount(1);
- assertThat(op.options().get("-dataproviderthreadcount")).isEqualTo("1");
+ assertThat(op.options.get("-dataproviderthreadcount")).isEqualTo("1");
}
@Test
void testDependencyInjectorFactory() {
var op = new TestNgOperation().dependencyInjectorFactory(FOO);
- assertThat(op.options().get("-dependencyinjectorfactory")).isEqualTo(FOO);
+ assertThat(op.options.get("-dependencyinjectorfactory")).isEqualTo(FOO);
}
@Test
void testDirectory() {
- var foo = new File("FOO");
-
var op = new TestNgOperation().directory(FOO);
- assertThat(op.options().get("-d")).as("as string").isEqualTo(FOO);
-
- op = new TestNgOperation().directory(foo);
- assertThat(op.options().get("-d")).as("as file").isEqualTo(foo.getAbsolutePath());
-
- op = new TestNgOperation().directory(foo.toPath());
- assertThat(op.options().get("-d")).as("as path").isEqualTo(foo.getAbsolutePath());
+ assertThat(op.options.get("-d")).isEqualTo(FOO);
}
@Test
void testExcludeGroups() {
var op = new TestNgOperation().excludeGroups(FOO, BAR);
- assertThat(op.options().get("-excludegroups")).isEqualTo(String.format("%s,%s", FOO, BAR));
+ assertThat(op.options.get("-excludegroups")).isEqualTo(String.format("%s,%s", FOO, BAR));
op = new TestNgOperation().excludeGroups(List.of(FOO, BAR));
- assertThat(op.options().get("-excludegroups")).as("as list").isEqualTo(String.format("%s,%s", FOO, BAR));
+ assertThat(op.options.get("-excludegroups")).as("as list").isEqualTo(String.format("%s,%s", FOO, BAR));
}
@Test
@@ -183,9 +97,10 @@ class TestNgOperationTest {
assertThatCode(() ->
new TestNgOperation().fromProject(new Project())
- .methods("rife.bld.extension.TestNgExampleTest.foo")
+ .testClass("rife.bld.extension.TestNgExampleTest")
+ .methods("rife.bld.extension.TestNgExampleTest.verifyHello")
.execute())
- .as("with methods").isInstanceOf(ExitStatusException.class);
+ .as("with methods").doesNotThrowAnyException();
assertThatCode(() ->
new TestNgOperation().fromProject(new Project())
@@ -220,304 +135,276 @@ class TestNgOperationTest {
@Test
void testFailWheneverEverythingSkipped() {
var op = new TestNgOperation().failWhenEverythingSkipped(false);
- assertThat(op.options().get("-failwheneverythingskipped")).isEqualTo("false");
+ assertThat(op.options.get("-failwheneverythingskipped")).isEqualTo("false");
op = new TestNgOperation().failWhenEverythingSkipped(true);
- assertThat(op.options().get("-failwheneverythingskipped")).isEqualTo("true");
+ assertThat(op.options.get("-failwheneverythingskipped")).isEqualTo("true");
}
@Test
void testFailurePolicy() {
var op = new TestNgOperation().failurePolicy(TestNgOperation.FailurePolicy.CONTINUE);
- assertThat(op.options().get("-configfailurepolicy")).isEqualTo("continue");
+ assertThat(op.options.get("-configfailurepolicy")).isEqualTo("continue");
op = new TestNgOperation().failurePolicy(TestNgOperation.FailurePolicy.SKIP);
- assertThat(op.options().get("-configfailurepolicy")).isEqualTo("skip");
+ assertThat(op.options.get("-configfailurepolicy")).isEqualTo("skip");
}
@Test
void testGenerateResultsPerSuite() {
var op = new TestNgOperation().generateResultsPerSuite(false);
- assertThat(op.options().get("-generateResultsPerSuite")).isEqualTo("false");
+ assertThat(op.options.get("-generateResultsPerSuite")).isEqualTo("false");
op = new TestNgOperation().generateResultsPerSuite(true);
- assertThat(op.options().get("-generateResultsPerSuite")).isEqualTo("true");
+ assertThat(op.options.get("-generateResultsPerSuite")).isEqualTo("true");
}
@Test
void testGroups() {
var op = new TestNgOperation().groups(FOO, BAR);
- assertThat(op.options().get("-groups")).isEqualTo(String.format("%s,%s", FOO, BAR));
-
- op.groups(List.of("group3", "group4"));
- assertThat(op.options().get("-groups")).isEqualTo("group3,group4");
-
+ assertThat(op.options.get("-groups")).isEqualTo(String.format("%s,%s", FOO, BAR));
}
@Test
void testIgnoreMissedTestName() {
var op = new TestNgOperation().ignoreMissedTestName(false);
- assertThat(op.options().get("-ignoreMissedTestNames")).isEqualTo("false");
+ assertThat(op.options.get("-ignoreMissedTestNames")).isEqualTo("false");
op = new TestNgOperation().ignoreMissedTestName(true);
- assertThat(op.options().get("-ignoreMissedTestNames")).isEqualTo("true");
+ assertThat(op.options.get("-ignoreMissedTestNames")).isEqualTo("true");
}
@Test
void testIncludeAllDataDrivenTestsWhenSkipping() {
var op = new TestNgOperation().includeAllDataDrivenTestsWhenSkipping(false);
- assertThat(op.options().get("-includeAllDataDrivenTestsWhenSkipping")).isEqualTo("false");
+ assertThat(op.options.get("-includeAllDataDrivenTestsWhenSkipping")).isEqualTo("false");
op = new TestNgOperation().includeAllDataDrivenTestsWhenSkipping(true);
- assertThat(op.options().get("-includeAllDataDrivenTestsWhenSkipping")).isEqualTo("true");
+ assertThat(op.options.get("-includeAllDataDrivenTestsWhenSkipping")).isEqualTo("true");
}
@Test
void testJar() {
var op = new TestNgOperation().testJar(FOO);
- assertThat(op.options().get("-testjar")).isEqualTo(FOO);
+ assertThat(op.options.get("-testjar")).isEqualTo(FOO);
}
@Test
void testJunit() {
var op = new TestNgOperation().jUnit(false);
- assertThat(op.options().get("-junit")).isEqualTo("false");
+ assertThat(op.options.get("-junit")).isEqualTo("false");
op = new TestNgOperation().jUnit(true);
- assertThat(op.options().get("-junit")).isEqualTo("true");
+ assertThat(op.options.get("-junit")).isEqualTo("true");
}
@Test
void testListener() {
var ops = new TestNgOperation().listener(FOO, BAR);
- assertThat(ops.options().get("-listener")).isEqualTo(String.format("%s,%s", FOO, BAR));
+ assertThat(ops.options.get("-listener")).isEqualTo(String.format("%s,%s", FOO, BAR));
ops = new TestNgOperation().listener(List.of(FOO, BAR));
- assertThat(ops.options().get("-listener")).as("as list").isEqualTo(String.format("%s,%s", FOO, BAR));
+ assertThat(ops.options.get("-listener")).as("as list").isEqualTo(String.format("%s,%s", FOO, BAR));
}
@Test
void testMethodDetectors() {
var op = new TestNgOperation().methodSelectors(FOO, BAR);
- assertThat(op.options().get("-methodselectors")).isEqualTo(String.format("%s,%s", FOO, BAR));
+ assertThat(op.options.get("-methodselectors")).isEqualTo(String.format("%s,%s", FOO, BAR));
op = new TestNgOperation().methodSelectors(List.of(FOO, BAR));
- assertThat(op.options().get("-methodselectors")).as("as list").isEqualTo(String.format("%s,%s", FOO, BAR));
+ assertThat(op.options.get("-methodselectors")).as("as list").isEqualTo(String.format("%s,%s", FOO, BAR));
}
@Test
void testMethods() {
var op = new TestNgOperation().methods(FOO, BAR);
- assertThat(op.methods()).containsExactly(BAR, FOO);
+ assertThat(op.options.get("-methods")).isEqualTo(String.format("%s,%s", FOO, BAR));
new TestNgOperation().methods(List.of(FOO, BAR));
- assertThat(op.methods()).containsExactly(BAR, FOO);
+ assertThat(op.options.get("-methods")).as("as list").isEqualTo(String.format("%s,%s", FOO, BAR));
}
@Test
void testMixed() {
var op = new TestNgOperation().mixed(false);
- assertThat(op.options().get("-mixed")).isEqualTo("false");
+ assertThat(op.options.get("-mixed")).isEqualTo("false");
op = new TestNgOperation().mixed(true);
- assertThat(op.options().get("-mixed")).isEqualTo("true");
+ assertThat(op.options.get("-mixed")).isEqualTo("true");
}
@Test
void testName() {
var op = new TestNgOperation().testName(FOO);
- assertThat(op.options().get("-testname")).isEqualTo("\"" + FOO + '\"');
+ assertThat(op.options.get("-testname")).isEqualTo("\"" + FOO + '\"');
}
@Test
void testNames() {
var ops = new TestNgOperation().testNames(FOO, BAR);
- assertThat(ops.options().get("-testnames")).isEqualTo(String.format("\"%s\",\"%s\"", FOO, BAR));
+ assertThat(ops.options.get("-testnames")).isEqualTo(String.format("\"%s\",\"%s\"", FOO, BAR));
new TestNgOperation().testNames(List.of(FOO, BAR));
- assertThat(ops.options().get("-testnames")).as("as list").isEqualTo(String.format("\"%s\",\"%s\"", FOO, BAR));
+ assertThat(ops.options.get("-testnames")).as("as list").isEqualTo(String.format("\"%s\",\"%s\"", FOO, BAR));
}
@Test
void testObjectFactory() {
var ops = new TestNgOperation().objectFactory(FOO, BAR);
- assertThat(ops.options().get("-objectfactory")).isEqualTo(String.format("%s,%s", FOO, BAR));
+ assertThat(ops.options.get("-objectfactory")).isEqualTo(String.format("%s,%s", FOO, BAR));
ops = new TestNgOperation().objectFactory(List.of(FOO, BAR));
- assertThat(ops.options().get("-objectfactory")).as("as list").isEqualTo(String.format("%s,%s", FOO, BAR));
+ assertThat(ops.options.get("-objectfactory")).as("as list").isEqualTo(String.format("%s,%s", FOO, BAR));
}
@Test
void testOverrideIncludedMethods() {
var ops = new TestNgOperation().overrideIncludedMethods(FOO, BAR);
- assertThat(ops.options().get("-overrideincludedmethods")).isEqualTo(String.format("%s,%s", FOO, BAR));
+ assertThat(ops.options.get("-overrideincludedmethods")).isEqualTo(String.format("%s,%s", FOO, BAR));
ops = new TestNgOperation().overrideIncludedMethods(List.of(FOO, BAR));
- assertThat(ops.options().get("-overrideincludedmethods")).as("as list").isEqualTo(String.format("%s,%s", FOO, BAR));
+ assertThat(ops.options.get("-overrideincludedmethods")).as("as list").isEqualTo(String.format("%s,%s", FOO, BAR));
}
@Test
void testPackages() {
var op = new TestNgOperation().packages(FOO, BAR);
- assertThat(op.packages()).contains(FOO).contains(BAR);
+ assertThat(op.packages).contains(FOO).contains(BAR);
op = new TestNgOperation().packages(List.of(FOO, BAR));
- assertThat(op.packages()).as("as list").contains(FOO).contains(BAR);
+ assertThat(op.packages).as("as list").contains(FOO).contains(BAR);
}
@Test
void testParallel() {
var op = new TestNgOperation().parallel(TestNgOperation.Parallel.TESTS);
- assertThat(op.options().get("-parallel")).isEqualTo("tests");
+ assertThat(op.options.get("-parallel")).isEqualTo("tests");
op = new TestNgOperation().parallel(TestNgOperation.Parallel.METHODS);
- assertThat(op.options().get("-parallel")).isEqualTo("methods");
+ assertThat(op.options.get("-parallel")).isEqualTo("methods");
op = new TestNgOperation().parallel(TestNgOperation.Parallel.CLASSES);
- assertThat(op.options().get("-parallel")).isEqualTo("classes");
+ assertThat(op.options.get("-parallel")).isEqualTo("classes");
}
@Test
void testPort() {
var op = new TestNgOperation().port(1);
- assertThat(op.options().get("-port")).isEqualTo("1");
+ assertThat(op.options.get("-port")).isEqualTo("1");
}
@Test
void testPropagateDataProviderFailureAsTestFailure() {
var op = new TestNgOperation().propagateDataProviderFailureAsTestFailure(false);
- assertThat(op.options().get("-propagateDataProviderFailureAsTestFailure")).isEqualTo("false");
+ assertThat(op.options.get("-propagateDataProviderFailureAsTestFailure")).isEqualTo("false");
op = new TestNgOperation().propagateDataProviderFailureAsTestFailure(true);
- assertThat(op.options().get("-propagateDataProviderFailureAsTestFailure")).isEqualTo("true");
+ assertThat(op.options.get("-propagateDataProviderFailureAsTestFailure")).isEqualTo("true");
}
@Test
void testReported() {
var op = new TestNgOperation().reporter(FOO);
- assertThat(op.options().get("-reporter")).isEqualTo(FOO);
+ assertThat(op.options.get("-reporter")).isEqualTo(FOO);
}
@Test
void testRunFactory() {
var op = new TestNgOperation().testRunFactory(FOO);
- assertThat(op.options().get("-testrunfactory")).isEqualTo(FOO);
+ assertThat(op.options.get("-testrunfactory")).isEqualTo(FOO);
}
@Test
void testShareThreadPoolForDataProviders() {
var op = new TestNgOperation().shareThreadPoolForDataProviders(true);
- assertThat(op.options().get("-shareThreadPoolForDataProviders")).isEqualTo("true");
+ assertThat(op.options.get("-shareThreadPoolForDataProviders")).isEqualTo("true");
op = new TestNgOperation().shareThreadPoolForDataProviders(false);
- assertThat(op.options().get("-shareThreadPoolForDataProviders")).isNull();
+ assertThat(op.options.get("-shareThreadPoolForDataProviders")).isNull();
}
@Test
void testSourceDir() {
- var foo = new File(FOO);
- var bar = new File(BAR);
-
- var foobar = String.format("%s;%s", FOO, BAR);
var op = new TestNgOperation().sourceDir(FOO, BAR);
- assertThat(op.options().get("-sourcedir")).as("String...").isEqualTo(foobar);
+ assertThat(op.options.get("-sourcedir")).isEqualTo(String.format("%s;%s", FOO, BAR));
op = new TestNgOperation().sourceDir(List.of(FOO, BAR));
- assertThat(op.options().get("-sourcedir")).as("List(String...)").isEqualTo(foobar);
-
- foobar = String.format("%s;%s", foo.getAbsolutePath(), bar.getAbsolutePath());
- op = new TestNgOperation().sourceDir(foo, bar);
- assertThat(op.options().get("-sourcedir")).as("File...").isEqualTo(foobar);
-
- op = new TestNgOperation().sourceDirFiles(List.of(foo, bar));
- assertThat(op.options().get("-sourcedir")).as("List(String...)").isEqualTo(foobar);
-
- op = new TestNgOperation().sourceDir(foo.toPath(), bar.toPath());
- assertThat(op.options().get("-sourcedir")).as("Path...").isEqualTo(foobar);
-
- op = new TestNgOperation().sourceDirPaths(List.of(foo.toPath(), bar.toPath()));
- assertThat(op.options().get("-sourcedir")).as("List(Path...)").isEqualTo(foobar);
+ assertThat(op.options.get("-sourcedir")).as("as list").isEqualTo(String.format("%s;%s", FOO, BAR));
}
@Test
void testSpiListenersToSkip() {
var ops = new TestNgOperation().spiListenersToSkip(FOO, BAR);
- assertThat(ops.options().get("-spilistenerstoskip")).isEqualTo(String.format("%s,%s", FOO, BAR));
+ assertThat(ops.options.get("-spilistenerstoskip")).isEqualTo(String.format("%s,%s", FOO, BAR));
ops = new TestNgOperation().spiListenersToSkip(List.of(FOO, BAR));
- assertThat(ops.options().get("-spilistenerstoskip")).as("as list").isEqualTo(String.format("%s,%s", FOO, BAR));
+ assertThat(ops.options.get("-spilistenerstoskip")).as("as list").isEqualTo(String.format("%s,%s", FOO, BAR));
}
@Test
void testSuiteName() {
var op = new TestNgOperation().suiteName(FOO);
- assertThat(op.options().get("-suitename")).isEqualTo("\"" + FOO + '\"');
+ assertThat(op.options.get("-suitename")).isEqualTo("\"" + FOO + '\"');
}
@Test
void testSuiteThreadPoolSize() {
var op = new TestNgOperation().suiteThreadPoolSize(1);
- assertThat(op.options().get("-suitethreadpoolsize")).isEqualTo("1");
+ assertThat(op.options.get("-suitethreadpoolsize")).isEqualTo("1");
}
@Test
void testSuites() {
var op = new TestNgOperation().suites(FOO, BAR);
- assertThat(op.suites()).contains(FOO).contains(BAR);
+ assertThat(op.suites).contains(FOO).contains(BAR);
op = new TestNgOperation().suites(List.of(FOO, BAR));
- assertThat(op.suites()).as("as list").contains(FOO).contains(BAR);
+ assertThat(op.suites).as("as list").contains(FOO).contains(BAR);
}
@Test
void testThreadCount() {
var op = new TestNgOperation().threadCount(1);
- assertThat(op.options().get("-threadcount")).isEqualTo("1");
+ assertThat(op.options.get("-threadcount")).isEqualTo("1");
}
@Test
void testThreadPoolFactoryClass() {
var op = new TestNgOperation().threadPoolFactoryClass(FOO);
- assertThat(op.options().get("-threadpoolfactoryclass")).isEqualTo(FOO);
+ assertThat(op.options.get("-threadpoolfactoryclass")).isEqualTo(FOO);
}
@Test
void testUseDefaultListeners() {
var op = new TestNgOperation().useDefaultListeners(false);
- assertThat(op.options().get("-usedefaultlisteners")).isEqualTo("false");
+ assertThat(op.options.get("-usedefaultlisteners")).isEqualTo("false");
op = new TestNgOperation().useDefaultListeners(true);
- assertThat(op.options().get("-usedefaultlisteners")).isEqualTo("true");
+ assertThat(op.options.get("-usedefaultlisteners")).isEqualTo("true");
}
@Test
void testUseGlobalThreadPool() {
var op = new TestNgOperation().useGlobalThreadPool(true);
- assertThat(op.options().get("-useGlobalThreadPool")).isEqualTo("true");
+ assertThat(op.options.get("-useGlobalThreadPool")).isEqualTo("true");
op = new TestNgOperation().useGlobalThreadPool(false);
- assertThat(op.options().get("-useGlobalThreadPool")).isNull();
+ assertThat(op.options.get("-useGlobalThreadPool")).isNull();
}
@Test
void testVerbose() {
var op = new TestNgOperation().log(1);
- assertThat(op.options().get("-log")).isEqualTo("1");
+ assertThat(op.options.get("-log")).isEqualTo("1");
op = new TestNgOperation().verbose(1);
- assertThat(op.options().get("-verbose")).isEqualTo("1");
+ assertThat(op.options.get("-verbose")).isEqualTo("1");
}
@Test
void testXmlPathInJar() {
- var foo = new File(FOO);
var op = new TestNgOperation().xmlPathInJar(FOO);
- assertThat(op.options().get("-xmlpathinjar")).as("as string").isEqualTo(FOO);
-
- op = new TestNgOperation().xmlPathInJar(foo);
- assertThat(op.options().get("-xmlpathinjar")).as("as file").isEqualTo(foo.getAbsolutePath());
-
- op = new TestNgOperation().xmlPathInJar(foo.toPath());
- assertThat(op.options().get("-xmlpathinjar")).as("as path").isEqualTo(foo.getAbsolutePath());
+ assertThat(op.options.get("-xmlpathinjar")).isEqualTo(FOO);
}
}
diff --git a/src/test/resources/testng-args.txt b/src/test/resources/testng-args.txt
deleted file mode 100644
index 8eec8d5..0000000
--- a/src/test/resources/testng-args.txt
+++ /dev/null
@@ -1,38 +0,0 @@
--alwaysrunlisteners
--configfailurepolicy
--d
--dataproviderthreadcount
--dependencyinjectorfactory
--excludegroups
--failwheneverythingskipped
--generateResultsPerSuite
--groups
--ignoreMissedTestNames
--includeAllDataDrivenTestsWhenSkipping
--listener
--listenercomparator
--listenerfactory
--log
--methods
--methodselectors
--mixed
--objectfactory
--overrideincludedmethods
--parallel
--propagateDataProviderFailureAsTestFailure
--reporter
--shareThreadPoolForDataProviders
--spilistenerstoskip
--suitename
--suitethreadpoolsize
--testclass
--testjar
--testname
--testnames
--testrunfactory
--threadcount
--threadpoolfactoryclass
--usedefaultlisteners
--useGlobalThreadPool
--verbose
--xmlpathinjar
diff --git a/src/test/resources/testng.xml b/src/test/resources/testng.xml
index ef68357..8ad378e 100644
--- a/src/test/resources/testng.xml
+++ b/src/test/resources/testng.xml
@@ -3,10 +3,6 @@
-
-
-
-
\ No newline at end of file