Package org.gradle.api.tasks.testing.testng

# 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.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `(package private) static class`
  `TestNGOptions.SuiteXmlAdapter`
  `(package private) static class`
  `TestNGOptions.SuiteXmlFilesAdapter`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `DEFAULT_CONFIG_FAILURE_POLICY`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `TestNGOptions(ProjectLayout projectLayout, ObjectFactory objects)`

- ## 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)`
  `abstract Property<String>`
  `getConfigFailurePolicy()`
  Option for what to do for other tests that use a configuration step when that step fails.
  `abstract SetProperty<String>`
  `getExcludeGroups()`
  The set of groups to exclude.
  `abstract Property<Boolean>`
  `getGroupByInstances()`
  Indicates whether the tests should be grouped by instances.
  `abstract SetProperty<String>`
  `getIncludeGroups()`
  The set of groups to run.
  `Property<Boolean>`
  `getIsGroupByInstances()`
  `Property<Boolean>`
  `getIsPreserveOrder()`
  `Property<Boolean>`
  `getIsUseDefaultListeners()`
  `abstract SetProperty<String>`
  `getListeners()`
  Fully qualified classes that are TestNG listeners (instances of org.testng.ITestListener or org.testng.IReporter).
  `abstract DirectoryProperty`
  `getOutputDirectory()`
  The location to write TestNG's output.
  `abstract Property<String>`
  `getParallel()`
  The parallel mode to use for running the tests - one of the following modes: methods, tests, classes or instances.
  `abstract Property<Boolean>`
  `getPreserveOrder()`
  Indicates whether the tests should be run in deterministic order.
  `protected File`
  `getProjectDir()`
  `abstract Property<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)`
  `abstract Property<Integer>`
  `getSuiteThreadPoolSize()`
  The number of XML suites will run parallel
  `protected Provider<String>`
  `getSuiteXml()`
  Returns the XML generated using `suiteXmlBuilder()`, if any.
  `Property<MarkupBuilder>`
  `getSuiteXmlBuilder()`
  `abstract ConfigurableFileCollection`
  `getSuiteXmlFiles()`
  The suiteXmlFiles to use for running TestNG.
  `Property<StringWriter>`
  `getSuiteXmlWriter()`
  `abstract Property<String>`
  `getTestName()`
  Sets the default name of the test, if one is not specified in a suite XML file or in the source code.
  `abstract Property<Integer>`
  `getThreadCount()`
  The number of threads to use for this run.
  `abstract Property<String>`
  `getThreadPoolFactoryClass()`
  ThreadPoolExecutorFactory class used by TestNG
  `abstract Property<Boolean>`
  `getUseDefaultListeners()`
  Whether the default listeners and reporters should be used.
  `TestNGOptions`
  `includeGroups(String... includeGroups)`
  `Object`
  `methodMissing(String name, Object args)`
  `Object`
  `propertyMissing(String name)`
  `void`
  `suites(File... suiteFiles)`
  Add suite files by File objects.
  `void`
  `suites(String... suiteFiles)`
  Add suite files by Strings.
  `MarkupBuilder`
  `suiteXmlBuilder()`
  `TestNGOptions`
  `useDefaultListeners()`
  `TestNGOptions`
  `useDefaultListeners(boolean useDefaultListeners)`

  ### Methods inherited from class java.lang.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
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### TestNGOptions

    @Inject public TestNGOptions(ProjectLayout projectLayout, ObjectFactory objects)

- ## 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()

  - ### suites

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

  - ### getProjectDir

    @Internal protected File getProjectDir()

  - ### suites

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

  - ### getSuites

    public List<File> getSuites(File testSuitesDir)

  - ### includeGroups

    public TestNGOptions includeGroups(String... includeGroups)

  - ### excludeGroups

    public TestNGOptions excludeGroups(String... excludeGroups)

  - ### useDefaultListeners

    public TestNGOptions useDefaultListeners()

  - ### useDefaultListeners

    public TestNGOptions useDefaultListeners(boolean useDefaultListeners)

  - ### propertyMissing

    public Object propertyMissing(String name)

  - ### methodMissing

    public Object methodMissing(String name, Object args)

  - ### getOutputDirectory

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

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

    Since:
      1.11

  - ### getIncludeGroups

    @Input public abstract SetProperty<String> getIncludeGroups()
    The set of groups to run.

  - ### getExcludeGroups

    @Input public abstract SetProperty<String> getExcludeGroups()
    The set of groups to exclude.

  - ### getConfigFailurePolicy

    @Internal public abstract Property<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".

  - ### getListeners

    @Internal public abstract SetProperty<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.add('org.testng.reporters.EmailableReporter')
             }
         }

  - ### getParallel

    @Internal public abstract Property<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

  - ### getThreadCount

    @Internal public abstract Property<Integer> getThreadCount()
    The number of threads to use for this run. Ignored unless the parallel mode is also specified

  - ### getSuiteThreadPoolSize

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

  - ### getThreadPoolFactoryClass

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

  - ### getUseDefaultListeners

    @Internal public abstract Property<Boolean> getUseDefaultListeners()
    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 `getListeners()` 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.

  - ### getIsUseDefaultListeners

    @Internal public Property<Boolean> getIsUseDefaultListeners()

  - ### getSuiteName

    @Internal public abstract Property<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.

  - ### getTestName

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

  - ### getSuiteXmlFiles

    @InputFiles @PathSensitive(NONE) public abstract ConfigurableFileCollection getSuiteXmlFiles()
    The suiteXmlFiles to use for running TestNG. Note: The suiteXmlFiles can be used in conjunction with the suiteXmlBuilder.

  - ### getPreserveOrder

    @Internal public abstract Property<Boolean> getPreserveOrder()
    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.

  - ### getIsPreserveOrder

    @Internal public Property<Boolean> getIsPreserveOrder()

  - ### getGroupByInstances

    @Internal public abstract Property<Boolean> getGroupByInstances()
    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.

  - ### getIsGroupByInstances

    @Internal public Property<Boolean> getIsGroupByInstances()

  - ### getSuiteXml

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

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

  - ### getSuiteXmlWriter

    @Internal public Property<StringWriter> getSuiteXmlWriter()

  - ### getSuiteXmlBuilder

    @Internal public Property<MarkupBuilder> getSuiteXmlBuilder()