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 Details

    • DEFAULT_CONFIG_FAILURE_POLICY

      public static final String DEFAULT_CONFIG_FAILURE_POLICY
      The default config failure policy.
      Since:
      2.3
      See Also:
  • 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