TestNGOptions (Gradle API 2.14.1)

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 class TestNGOptions
      extends TestFrameworkOptions

  The TestNG specific test options.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `DEFAULT_CONFIG_FAILURE_POLICY`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `TestNGOptions(File projectDir)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `TestNGOptions` | `excludeGroups(String... excludeGroups)`
    `String` | `getAnnotations()` Deprecated.
    `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()`
    `Set<String>` | `getIncludeGroups()` The set of groups to run.
    `static String` | `getJAVADOC_ANNOTATIONS()` Deprecated.
    `boolean` | `getJavadocAnnotations()` Deprecated.
    `static String` | `getJDK_ANNOTATIONS()` Deprecated.
    `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.
    `String` | `getParallel()` The parallel mode to use for running the tests - one of the following modes: methods, tests, classes or instances.
    `boolean` | `getPreserveOrder()`
    `protected File` | `getProjectDir()`
    `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)`
    `MarkupBuilder` | `getSuiteXmlBuilder()`
    `List<File>` | `getSuiteXmlFiles()` The suiteXmlFiles to use for running TestNG.
    `StringWriter` | `getSuiteXmlWriter()`
    `String` | `getTestName()` Sets the default name of the test, if one is not specified in a suite XML file or in the source code.
    `List` | `getTestResources()` Deprecated.
    `int` | `getThreadCount()` The number of threads to use for this run.
    `boolean` | `getUseDefaultListeners()`
    `TestNGOptions` | `includeGroups(String... includeGroups)`
    `boolean` | `isGroupByInstances()` Indicates whether the tests should be grouped by instances.
    `boolean` | `isJavadocAnnotations()` Deprecated.
    `boolean` | `isPreserveOrder()` Indicates whether the tests should be run in deterministic order.
    `boolean` | `isUseDefaultListeners()` Whether the default listeners and reporters should be used.
    `TestNGOptions` | `javadocAnnotations()` Deprecated.
    `TestNGOptions` | `jdkAnnotations()` Deprecated.
    `Object` | `methodMissing(String name, Object args)`
    `Object` | `propertyMissing(String name)`
    `void` | `setAnnotationsOnSourceCompatibility(JavaVersion sourceCompatibilityProp)` Deprecated.
    `void` | `setConfigFailurePolicy(String configFailurePolicy)`
    `void` | `setExcludeGroups(Set<String> excludeGroups)`
    `void` | `setGroupByInstances(boolean groupByInstances)`
    `void` | `setIncludeGroups(Set<String> includeGroups)`
    `void` | `setJavadocAnnotations(boolean javadocAnnotations)` Deprecated.
    `void` | `setListeners(Set<String> listeners)`
    `void` | `setOutputDirectory(File outputDirectory)`
    `void` | `setParallel(String parallel)`
    `void` | `setPreserveOrder(boolean preserveOrder)`
    `void` | `setSuiteName(String suiteName)`
    `void` | `setSuiteXmlBuilder(MarkupBuilder suiteXmlBuilder)`
    `void` | `setSuiteXmlFiles(List<File> suiteXmlFiles)`
    `void` | `setSuiteXmlWriter(StringWriter suiteXmlWriter)`
    `void` | `setTestName(String testName)`
    `void` | `setTestResources(List testResources)` Deprecated.
    `void` | `setThreadCount(int threadCount)`
    `void` | `setUseDefaultListeners(boolean useDefaultListeners)`
    `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 Detail

    - #### DEFAULT_CONFIG_FAILURE_POLICY

          public static final String DEFAULT_CONFIG_FAILURE_POLICY

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### TestNGOptions

          public TestNGOptions(File projectDir)

  - ### Method Detail

    - #### getAnnotations

          @Deprecated
          public String getAnnotations()

      Deprecated.

    - #### setAnnotationsOnSourceCompatibility

          @Deprecated
          public void setAnnotationsOnSourceCompatibility(JavaVersion sourceCompatibilityProp)

      Deprecated.

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

          protected File getProjectDir()

    - #### suites

          public void suites(File... suiteFiles)

      Add suite files by File objects.

    - #### getSuites

          public List<File> getSuites(File testSuitesDir)

    - #### jdkAnnotations

          @Deprecated
          public TestNGOptions jdkAnnotations()

      Deprecated.

    - #### javadocAnnotations

          @Deprecated
          public TestNGOptions javadocAnnotations()

      Deprecated.

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

    - #### getJDK_ANNOTATIONS

          @Deprecated
          public static String getJDK_ANNOTATIONS()

      Deprecated.

    - #### getJAVADOC_ANNOTATIONS

          @Deprecated
          public static String getJAVADOC_ANNOTATIONS()

      Deprecated.

    - #### getOutputDirectory

          @Incubating
          @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

          @Incubating
          public void setOutputDirectory(File outputDirectory)

    - #### getJavadocAnnotations

          @Deprecated
          public boolean getJavadocAnnotations()

      Deprecated.
      When true, Javadoc annotations are used for these tests. When false, JDK annotations are used. If you use Javadoc annotations, you will also need to specify "sourcedir". Defaults to JDK annotations if you're using the JDK 5 jar and to Javadoc annotations if you're using the JDK 1.4 jar.

    - #### isJavadocAnnotations

          @Deprecated
          public boolean isJavadocAnnotations()

      Deprecated.

    - #### setJavadocAnnotations

          @Deprecated
          public void setJavadocAnnotations(boolean javadocAnnotations)

      Deprecated.

    - #### getTestResources

          @Deprecated
          public List getTestResources()

      Deprecated.
      List of all directories containing Test sources. Should be set if annotations is 'Javadoc'.

    - #### setTestResources

          @Deprecated
          public void setTestResources(List testResources)

      Deprecated.

    - #### getIncludeGroups

          public Set<String> getIncludeGroups()

      The set of groups to run.

    - #### setIncludeGroups

          public void setIncludeGroups(Set<String> includeGroups)

    - #### getExcludeGroups

          public Set<String> getExcludeGroups()

      The set of groups to exclude.

    - #### setExcludeGroups

          public void setExcludeGroups(Set<String> excludeGroups)

    - #### getConfigFailurePolicy

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

    - #### setConfigFailurePolicy

          public void setConfigFailurePolicy(String configFailurePolicy)

    - #### getListeners

          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:

           apply plugin: 'java'

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

    - #### setListeners

          public void setListeners(Set<String> listeners)

    - #### getParallel

          public 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

    - #### setParallel

          public void setParallel(String parallel)

    - #### getThreadCount

          public int getThreadCount()

      The number of threads to use for this run. Ignored unless the parallel mode is also specified

    - #### setThreadCount

          public void setThreadCount(int threadCount)

    - #### getUseDefaultListeners

          public boolean getUseDefaultListeners()

    - #### isUseDefaultListeners

          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):

           apply plugin: '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.enabled = 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.

    - #### setUseDefaultListeners

          public void setUseDefaultListeners(boolean useDefaultListeners)

    - #### getSuiteName

          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.

    - #### setSuiteName

          public void setSuiteName(String suiteName)

    - #### getTestName

          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.

    - #### setTestName

          public void setTestName(String testName)

    - #### getSuiteXmlFiles

          public List<File> getSuiteXmlFiles()

      The suiteXmlFiles to use for running TestNG. Note: The suiteXmlFiles can be used in conjunction with the suiteXmlBuilder.

    - #### setSuiteXmlFiles

          public void setSuiteXmlFiles(List<File> suiteXmlFiles)

    - #### getPreserveOrder

          public boolean getPreserveOrder()

    - #### isPreserveOrder

          @Incubating
          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.

    - #### setPreserveOrder

          @Incubating
          public void setPreserveOrder(boolean preserveOrder)

    - #### getGroupByInstances

          @Incubating
          public boolean getGroupByInstances()

    - #### isGroupByInstances

          @Incubating
          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.

    - #### setGroupByInstances

          @Incubating
          public void setGroupByInstances(boolean groupByInstances)

    - #### getSuiteXmlWriter

          public StringWriter getSuiteXmlWriter()

    - #### setSuiteXmlWriter

          public void setSuiteXmlWriter(StringWriter suiteXmlWriter)

    - #### getSuiteXmlBuilder

          public MarkupBuilder getSuiteXmlBuilder()

    - #### setSuiteXmlBuilder

          public void setSuiteXmlBuilder(MarkupBuilder suiteXmlBuilder)