Default is {@code true}
* * @param isAlwaysRunListeners {@code true} or {@code false} * @return this operation instance */ public TestNgOperation alwaysRunListeners(Boolean isAlwaysRunListeners) { options_.put("-alwaysrunlisteners", String.valueOf(isAlwaysRunListeners)); return this; } /** * This sets the default maximum number of threads to use for data providers when running tests in parallel. * It will only take effect if the parallel mode has been selected (for example,with the * {@link #parallel(Parallel) parallel} option). This can be overridden in the suite definition. * * @param count the count * @return this operation instance */ public TestNgOperation dataProviderThreadCount(int count) { if (count >= 0) { options_.put("-dataproviderthreadcount", String.valueOf(count)); } return this; } /** * The dependency injector factory implementation that TestNG should use. * * @param injectorFactory the injector factory * @return this operation instance */ public TestNgOperation dependencyInjectorFactory(String injectorFactory) { if (isNotBlank(injectorFactory)) { options_.put("-dependencyinjectorfactory", injectorFactory); } return this; } /** * The directory where the reports will be generated * *Default is {@code build/test-output})
* * @param directoryPath the directory path * @return this operation instance */ public TestNgOperation directory(String directoryPath) { if (isNotBlank(directoryPath)) { options_.put("-d", directoryPath); } return this; } /** * The list of groups you want to be excluded from this run. * * @param group one or more groups * @return this operation instance * @see #excludeGroups(Collection) #excludeGroups(Collection) */ public TestNgOperation excludeGroups(String... group) { options_.put("-excludegroups", String.join(",", Arrays.stream(group).filter(this::isNotBlank).toList())); return this; } /** * The list of groups you want to be excluded from this run. * * @param group the list of groups * @return this operation instance * @see #excludeGroups(String...) #excludeGroups(String...) */ public TestNgOperation excludeGroups(CollectionDefault is {@code false}
. * * @param resultsPerSuite {@code true} or {@code false} * @return this operation instance */ public TestNgOperation generateResultsPerSuite(Boolean resultsPerSuite) { options_.put("-generateResultsPerSuite", String.valueOf(resultsPerSuite)); return this; } /** * The list of groups you want to run. * *For example: {@code "windows", "linux", "regression}
* * @param group one or more groups * @return this operation instance * @see #groups(Collection) #groups(Collection) */ public TestNgOperation groups(String... group) { options_.put("-groups", String.join(",", Arrays.stream(group).filter(this::isNotBlank).toList())); return this; } /** * The list of groups you want to run. * *For example: {@code "windows", "linux", "regression}
* * @param group the list of groups * @return this operation instance * @see #groups(String...) #groups(String...) */ public TestNgOperation groups(CollectionDefault is {@code false}
* * @param isIgnoreMissedTestNames {@code true} or {@code false} * @return this operation instance */ public TestNgOperation ignoreMissedTestName(Boolean isIgnoreMissedTestNames) { options_.put("-ignoreMissedTestNames", String.valueOf(isIgnoreMissedTestNames)); return this; } /** * Should TestNG report all iterations of a data driven test as individual skips, in-case of upstream failures. * *Default is {@code false}
* * @param isIncludeDrivenTestsWhenSkipping {@code true} or {@code false} * @return this operation instance */ public TestNgOperation includeAllDataDrivenTestsWhenSkipping(Boolean isIncludeDrivenTestsWhenSkipping) { options_.put("-includeAllDataDrivenTestsWhenSkipping", String.valueOf(isIncludeDrivenTestsWhenSkipping)); return this; } /* * Determines if a string is not blank. */ private boolean isNotBlank(String s) { return s != null && !s.isBlank(); } /** * Enables or disables the JUnit mode. * *Default is {@code false}
* * @param isJunit {@code true} or {@code false} * @return this operation instance */ public TestNgOperation jUnit(Boolean isJunit) { options_.put("-junit", String.valueOf(isJunit)); return this; } /** * The list of {@code .class} files or list of class names implementing {@code ITestListener} or * {@code ISuiteListener} * * @param listener one or more listeners * @return this operation instance * @see #listener(Collection) #listener(Collection) */ public TestNgOperation listener(String... listener) { options_.put("-listener", String.join(",", Arrays.stream(listener).filter(this::isNotBlank).toList())); return this; } /** * The list of {@code .class} files or list of class names implementing {@code ITestListener} or * {@code ISuiteListener} * * @param listener the list of listeners * @return this operation instance * @see #listener(String...) #listener(String...) */ public TestNgOperation listener(CollectionFor example: {@code "com.example.Selector1:3", "com.example.Selector2:2"}
* * @param selector one or more selectors * @return this operation instance * @see #methodSelectors(Collection) #methodSelectors(Collection) */ public TestNgOperation methodSelectors(String... selector) { options_.put("-methodselectors", String.join(",", Arrays.stream(selector).filter(this::isNotBlank).toList())); return this; } /** * Specifies the list of {@code .class} files or class names implementing {@code IMethodSelector}. * *For example: {@code "com.example.Selector1:3", "com.example.Selector2:2"}
* * @param selector the list of selectors * @return this operation instance * @see #methodSelectors(String...) #methodSelectors(String...) */ public TestNgOperation methodSelectors(CollectionFor example: {@code "com.example.Foo.f1", "com.example.Bar.f2"}
* * @param method one or more methods * @return this operation instance * @see #methods(Collection) #methods(Collection) */ public TestNgOperation methods(String... method) { methods_.addAll(List.of(method)); return this; } /** * Lets you specify individual methods to run. * *For example: {@code "com.example.Foo.f1", "com.example.Bar.f2"}
* * @param method the list of methods * @return this operation instance * @see #methods(String...) #methods(String...) */ public TestNgOperation methods(CollectionDefault is {@code false}
* * @param isMixed {@code true} or {@code false} * @return this operation instance */ public TestNgOperation mixed(Boolean 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}. * * @param factory one or more factories * @return this operation instance * @see #objectFactory(Collection) #objectFactory(Collection) */ public TestNgOperation objectFactory(String... 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}. * * @param factory the list of factories * @return this operation instance * @see #objectFactory(String...) #objectFactory(String...) */ public TestNgOperation objectFactory(CollectionFor example: {@code "com.example", "test.sample.*"}
* * @param name one or more names * @return this operation instance * @see #packages(Collection) #packages(Collection) */ public TestNgOperation packages(String... name) { packages_.addAll(Arrays.stream(name).filter(this::isNotBlank).toList()); return this; } /** * The list of packages to include in this test. * If the package name ends with .* then subpackages are included too. * Required if no {@link #suites(String... suites)} specified. * *For example: {@code "com.example", "test.sample.*"}
* * @param name the list of names * @return this operation instance * @see #packages(String...) #packages(String...) */ public TestNgOperation packages(CollectionDefault is {@code false}
* * @param isPropagateDataProviderFailure {@code true} or {@code false} * @return this operation instance */ public TestNgOperation propagateDataProviderFailureAsTestFailure(Boolean isPropagateDataProviderFailure) { options_.put("-propagateDataProviderFailureAsTestFailure", String.valueOf(isPropagateDataProviderFailure)); return this; } /** * Specifies the extended configuration for custom report listener. * * @param reporter the reporter * @return this operation instance */ public TestNgOperation reporter(String reporter) { if (isNotBlank(reporter)) { options_.put("-reporter", reporter); } return this; } /** * Should TestNG use a global Shared ThreadPool (At suite level) for running data providers. * * @param shareThreadPoolForDataProviders {@code true} or {@code false} * @return this operation instance */ public TestNgOperation shareThreadPoolForDataProviders(boolean shareThreadPoolForDataProviders) { if (shareThreadPoolForDataProviders) { options_.put("-shareThreadPoolForDataProviders", "true"); } return this; } /** * 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 #sourceDir(String...) #sourceDir(String...) */ public TestNgOperation sourceDir(String... directory) { options_.put("-sourcedir", String.join(";", Arrays.stream(directory).filter(this::isNotBlank).toList())); return this; } /** * 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...) #sourceDir(String...) */ public TestNgOperation sourceDir(CollectionFor example: {@code "testng.xml", "testng2.xml"}
* * @param suite one or more suites * @return this operation instance * @see #suites(Collection) #suites(Collection) */ public TestNgOperation suites(String... suite) { suites_.addAll(Arrays.stream(suite).filter(this::isNotBlank).toList()); return this; } /** * Specifies the suites to run. * *For example: {@code "testng.xml", "testng2.xml"}
* * @param suite the list of suites * @return this operation instance * @see #suites(String...) #suites(String...) */ public TestNgOperation suites(CollectionFor example: {@code "org.foo.Test1","org.foo.test2"}
* * @param aClass one or more classes * @return this operation instance * @see #testClass(Collection) #testClass(Collection) */ public TestNgOperation testClass(String... aClass) { options_.put("-testclass", String.join(",", Arrays.stream(aClass).filter(this::isNotBlank).toList())); return this; } /** * Specifies the list of class files. * *For example: {@code "org.foo.Test1","org.foo.test2"}
* * @param aClass the list of classes * @return this operation instance * @see #testClass(String...) #testClass(String...) */ public TestNgOperation testClass(CollectionDefault is {@code true}
* * @param isDefaultListener {@code true} or {@code false} * @return this operation instance */ public TestNgOperation useDefaultListeners(Boolean isDefaultListener) { options_.put("-usedefaultlisteners", String.valueOf(isDefaultListener)); return this; } /** * Should TestNG use a global Shared ThreadPool (At suite level) for running regular and data driven tests. * * @param useGlobalThreadPool {@code true} or {@code false} * @return this operation instance */ public TestNgOperation useGlobalThreadPool(boolean useGlobalThreadPool) { if (useGlobalThreadPool) { options_.put("-useGlobalThreadPool", "true"); } return this; } /** * Set the Level of verbosity. * * @param level the level * @return this operation instance * @see #log(int) #log(int) */ public TestNgOperation verbose(int level) { if (level >= 0) { options_.put("-verbose", String.valueOf(level)); } return this; } private File writeDefaultSuite() throws IOException { var temp = tempFile(); try (var bufWriter = Files.newBufferedWriter(Paths.get(temp.getPath()))) { bufWriter.write("" + "" + "