# Class TestNGOptions

java.lang.Object
org.gradle.api.tasks.testing.TestFrameworkOptions
org.gradle.api.tasks.testing.testng.TestNGOptions

public abstract class TestNGOptions extends TestFrameworkOptions
The TestNG specific test options.

Since:
  0.7

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `DEFAULT_CONFIG_FAILURE_POLICY`
  The default config failure policy.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `TestNGOptions(ProjectLayout projectLayout)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `copyFrom(TestNGOptions other)`
  Copies the options from the source options into the current one.
  `TestNGOptions`
  `excludeGroups(String... excludeGroups)`
  Exclude groups.
  `String`
  `getConfigFailurePolicy()`
  Option for what to do for other tests that use a configuration step when that step fails.
  `Set<String>`
  `getExcludeGroups()`
  The set of groups to exclude.
  `boolean`
  `getGroupByInstances()`
  Returns the group by instances.
  `Set<String>`
  `getIncludeGroups()`
  The set of groups to run.
  `Set<String>`
  `getListeners()`
  Fully qualified classes that are TestNG listeners (instances of org.testng.ITestListener or org.testng.IReporter).
  `File`
  `getOutputDirectory()`
  The location to write TestNG's output.
  `@Nullable String`
  `getParallel()`
  The parallel mode to use for running the tests - one of the following modes: methods, tests, classes or instances.
  `boolean`
  `getPreserveOrder()`
  Returns the preserve order.
  `protected File`
  `getProjectDir()`
  Returns the project dir.
  `String`
  `getSuiteName()`
  Sets the default name of the test suite, if one is not specified in a suite XML file or in the source code.
  `List<File>`
  `getSuites(File testSuitesDir)`
  Returns the suites.
  `abstract Property<Integer>`
  `getSuiteThreadPoolSize()`
  The number of XML suites will run parallel
  `protected String`
  `getSuiteXml()`
  Returns the XML generated using `suiteXmlBuilder()`, if any.
  `MarkupBuilder`
  `getSuiteXmlBuilder()`
  Returns the suite xml builder.
  `List<File>`
  `getSuiteXmlFiles()`
  The suiteXmlFiles to use for running TestNG.
  `StringWriter`
  `getSuiteXmlWriter()`
  Returns the suite xml writer.
  `String`
  `getTestName()`
  Sets the default name of the test, if one is not specified in a suite XML file or in the source code.
  `int`
  `getThreadCount()`
  The number of threads to use for this run.
  `String`
  `getThreadPoolFactoryClass()`
  ThreadPoolExecutorFactory class used by TestNG
  `boolean`
  `getUseDefaultListeners()`
  Returns the use default listeners.
  `TestNGOptions`
  `includeGroups(String... includeGroups)`
  Include groups.
  `boolean`
  `isGroupByInstances()`
  Indicates whether the tests should be grouped by instances.
  `boolean`
  `isPreserveOrder()`
  Indicates whether the tests should be run in deterministic order.
  `boolean`
  `isUseDefaultListeners()`
  Whether the default listeners and reporters should be used.
  `Object`
  `methodMissing(String name, Object args)`
  Method missing.
  `Object`
  `propertyMissing(String name)`
  Property missing.
  `void`
  `setConfigFailurePolicy(String configFailurePolicy)`
  Sets the config failure policy.
  `void`
  `setExcludeGroups(Set<String> excludeGroups)`
  Sets the exclude groups.
  `void`
  `setGroupByInstances(boolean groupByInstances)`
  Sets the group by instances.
  `void`
  `setIncludeGroups(Set<String> includeGroups)`
  Sets the include groups.
  `void`
  `setListeners(Set<String> listeners)`
  Sets the listeners.
  `void`
  `setOutputDirectory(File outputDirectory)`
  Sets the output directory.
  `void`
  `setParallel(@Nullable String parallel)`
  Sets the parallel.
  `void`
  `setPreserveOrder(boolean preserveOrder)`
  Sets the preserve order.
  `void`
  `setSuiteName(String suiteName)`
  Sets the suite name.
  `void`
  `setSuiteXmlBuilder(MarkupBuilder suiteXmlBuilder)`
  Sets the suite xml builder.
  `void`
  `setSuiteXmlFiles(List<File> suiteXmlFiles)`
  Sets the suite xml files.
  `void`
  `setSuiteXmlWriter(StringWriter suiteXmlWriter)`
  Sets the suite xml writer.
  `void`
  `setTestName(String testName)`
  Sets the test name.
  `void`
  `setThreadCount(int threadCount)`
  Sets the thread count.
  `void`
  `setThreadPoolFactoryClass(String threadPoolFactoryClass)`
  Sets a custom threadPoolExecutorFactory class.
  `void`
  `setUseDefaultListeners(boolean useDefaultListeners)`
  Sets the use default listeners.
  `void`
  `suites(File... suiteFiles)`
  Add suite files by File objects.
  `void`
  `suites(String... suiteFiles)`
  Add suite files by Strings.
  `MarkupBuilder`
  `suiteXmlBuilder()`
  Suite xml builder.
  `TestNGOptions`
  `useDefaultListeners()`
  Use default listeners.
  `TestNGOptions`
  `useDefaultListeners(boolean useDefaultListeners)`
  Use default listeners.

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### DEFAULT_CONFIG_FAILURE_POLICY

    public static final String DEFAULT_CONFIG_FAILURE_POLICY
    The default config failure policy.
    Since:
      2.3
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### TestNGOptions

    @Inject public TestNGOptions(ProjectLayout projectLayout)

- ## Method Details

  - ### copyFrom

    public void copyFrom(TestNGOptions other)
    Copies the options from the source options into the current one.
    Since:
      8.0

  - ### suiteXmlBuilder

    public MarkupBuilder suiteXmlBuilder()
    Suite xml builder.
    Since:
      0.7

  - ### suites

    public void suites(String... suiteFiles)
    Add suite files by Strings. Each suiteFile String should be a path relative to the project root.
    Since:
      0.7

  - ### getProjectDir

    @Internal protected File getProjectDir()
    Returns the project dir.
    Since:
      1.12

  - ### suites

    public void suites(File... suiteFiles)
    Add suite files by File objects.
    Since:
      0.7

  - ### getSuites

    public List<File> getSuites(File testSuitesDir)
    Returns the suites.
    Since:
      0.7

  - ### includeGroups

    public TestNGOptions includeGroups(String... includeGroups)
    Include groups.
    Since:
      0.7

  - ### excludeGroups

    public TestNGOptions excludeGroups(String... excludeGroups)
    Exclude groups.
    Since:
      0.7

  - ### useDefaultListeners

    public TestNGOptions useDefaultListeners()
    Use default listeners.
    Since:
      0.8

  - ### useDefaultListeners

    public TestNGOptions useDefaultListeners(boolean useDefaultListeners)
    Use default listeners.
    Since:
      0.8

  - ### propertyMissing

    public Object propertyMissing(String name)
    Property missing.
    Since:
      0.7

  - ### methodMissing

    public Object methodMissing(String name, Object args)
    Method missing.
    Since:
      0.7

  - ### getOutputDirectory

    @OutputDirectory public File getOutputDirectory()
    The location to write TestNG's output.

    Defaults to the owning test task's location for writing the HTML report.

    Since:
      1.11

  - ### setOutputDirectory

    public void setOutputDirectory(File outputDirectory)
    Sets the output directory.
    Since:
      1.11

  - ### getIncludeGroups

    @Input public Set<String> getIncludeGroups()
    The set of groups to run.
    Since:
      0.7

  - ### setIncludeGroups

    public void setIncludeGroups(Set<String> includeGroups)
    Sets the include groups.
    Since:
      0.9

  - ### getExcludeGroups

    @Input public Set<String> getExcludeGroups()
    The set of groups to exclude.
    Since:
      0.7

  - ### setExcludeGroups

    public void setExcludeGroups(Set<String> excludeGroups)
    Sets the exclude groups.
    Since:
      0.9

  - ### getConfigFailurePolicy

    @Internal public String getConfigFailurePolicy()
    Option for what to do for other tests that use a configuration step when that step fails. Can be "skip" or "continue", defaults to "skip".
    Since:
      2.3

  - ### setConfigFailurePolicy

    public void setConfigFailurePolicy(String configFailurePolicy)
    Sets the config failure policy.
    Since:
      2.3

  - ### getListeners

    @Internal public Set<String> getListeners()
    Fully qualified classes that are TestNG listeners (instances of org.testng.ITestListener or org.testng.IReporter). By default, the listeners set is empty. Configuring extra listener:

        plugins {
            id 'java'
        }

        test {
            useTestNG() {
                // creates emailable HTML file
                // this reporter typically ships with TestNG library
                listeners << 'org.testng.reporters.EmailableReporter'
            }
        }

    Since:
      0.7

  - ### setListeners

    public void setListeners(Set<String> listeners)
    Sets the listeners.
    Since:
      0.9

  - ### getParallel

    @Internal public @Nullable String getParallel()
    The parallel mode to use for running the tests - one of the following modes: methods, tests, classes or instances. Not required. If not present, parallel mode will not be selected
    Since:
      0.7

  - ### setParallel

    public void setParallel(@Nullable String parallel)
    Sets the parallel.
    Since:
      0.7

  - ### getThreadCount

    @Internal public int getThreadCount()
    The number of threads to use for this run. Ignored unless the parallel mode is also specified
    Since:
      0.7

  - ### setThreadCount

    public void setThreadCount(int threadCount)
    Sets the thread count.
    Since:
      0.7

  - ### getSuiteThreadPoolSize

    @Internal @Incubating public abstract Property<Integer> getSuiteThreadPoolSize()
    The number of XML suites will run parallel
    Since:
      8.9

  - ### getUseDefaultListeners

    @Internal public boolean getUseDefaultListeners()
    Returns the use default listeners.
    Since:
      0.8

  - ### getThreadPoolFactoryClass

    @Internal @Incubating public String getThreadPoolFactoryClass()
    ThreadPoolExecutorFactory class used by TestNG
    Since:
      8.7

  - ### isUseDefaultListeners

    @Internal public boolean isUseDefaultListeners()
    Whether the default listeners and reporters should be used. Since Gradle 1.4 it defaults to 'false' so that Gradle can own the reports generation and provide various improvements. This option might be useful for advanced TestNG users who prefer the reports generated by the TestNG library. If you cannot live without some specific TestNG reporter please use `listeners` property. If you really want to use all default TestNG reporters (e.g. generate the old reports):

        plugins {
            id 'java'
        }

        test {
            useTestNG() {
                // report generation delegated to TestNG library:
                useDefaultListeners = true
            }

            // turn off Gradle's HTML report to avoid replacing the
            // reports generated by TestNG library:
            reports.html.required = false
        }

    Please refer to the documentation of your version of TestNG what are the default listeners. At the moment of writing this documentation, the default listeners are a set of reporters that generate: TestNG variant of HTML results, TestNG variant of XML results in JUnit format, emailable HTML test report, XML results in TestNG format.
    Since:
      0.8

  - ### setUseDefaultListeners

    public void setUseDefaultListeners(boolean useDefaultListeners)
    Sets the use default listeners.
    Since:
      0.8

  - ### setThreadPoolFactoryClass

    @Incubating public void setThreadPoolFactoryClass(String threadPoolFactoryClass)
    Sets a custom threadPoolExecutorFactory class. This should be a fully qualified class name of a class with a public no-arg constructor. For TestNG 7.10 and above, the class should implement `org.testng.IExecutorServiceFactory`. For TestNG 7.0 through 7.9, the class should implement `org.testng.thread.IExecutorFactory`. More details in testng#2042 and testng#3095. Requires TestNG 7.0 or higher.
    Since:
      8.7

  - ### getSuiteName

    @Internal public String getSuiteName()
    Sets the default name of the test suite, if one is not specified in a suite XML file or in the source code.
    Since:
      0.7

  - ### setSuiteName

    public void setSuiteName(String suiteName)
    Sets the suite name.
    Since:
      0.7

  - ### getTestName

    @Internal public String getTestName()
    Sets the default name of the test, if one is not specified in a suite XML file or in the source code.
    Since:
      0.7

  - ### setTestName

    public void setTestName(String testName)
    Sets the test name.
    Since:
      0.7

  - ### getSuiteXmlFiles

    @InputFiles @PathSensitive(NONE) public List<File> getSuiteXmlFiles()
    The suiteXmlFiles to use for running TestNG. Note: The suiteXmlFiles can be used in conjunction with the suiteXmlBuilder.
    Since:
      0.7

  - ### setSuiteXmlFiles

    public void setSuiteXmlFiles(List<File> suiteXmlFiles)
    Sets the suite xml files.
    Since:
      0.7

  - ### getPreserveOrder

    @Internal public boolean getPreserveOrder()
    Returns the preserve order.
    Since:
      2.11

  - ### isPreserveOrder

    @Internal public boolean isPreserveOrder()
    Indicates whether the tests should be run in deterministic order. Preserving the order guarantees that the complete test (including @BeforeXXX and @AfterXXX) is run in a test thread before the next test is run. Not required. If not present, the order will not be preserved.
    Since:
      2.11

  - ### setPreserveOrder

    public void setPreserveOrder(boolean preserveOrder)
    Sets the preserve order.
    Since:
      2.11

  - ### getGroupByInstances

    @Internal public boolean getGroupByInstances()
    Returns the group by instances.
    Since:
      2.11

  - ### isGroupByInstances

    @Internal public boolean isGroupByInstances()
    Indicates whether the tests should be grouped by instances. Grouping by instances will result in resolving test method dependencies for each instance instead of running the dependees of all instances before running the dependants. Not required. If not present, the tests will not be grouped by instances.
    Since:
      2.11

  - ### setGroupByInstances

    public void setGroupByInstances(boolean groupByInstances)
    Sets the group by instances.
    Since:
      2.11

  - ### getSuiteXml

    @Input @Optional protected String getSuiteXml()
    Returns the XML generated using `suiteXmlBuilder()`, if any.

    This property is read-only and exists merely for up-to-date checking.

    Since:
      6.0

  - ### getSuiteXmlWriter

    @Internal public StringWriter getSuiteXmlWriter()
    Returns the suite xml writer.
    Since:
      0.7

  - ### setSuiteXmlWriter

    public void setSuiteXmlWriter(StringWriter suiteXmlWriter)
    Sets the suite xml writer.
    Since:
      0.7

  - ### getSuiteXmlBuilder

    @Internal public MarkupBuilder getSuiteXmlBuilder()
    Returns the suite xml builder.
    Since:
      0.7

  - ### setSuiteXmlBuilder

    public void setSuiteXmlBuilder(MarkupBuilder suiteXmlBuilder)
    Sets the suite xml builder.
    Since:
      0.7