Class TestNGOptions


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

      • DEFAULT_CONFIG_FAILURE_POLICY

        public static final java.lang.String DEFAULT_CONFIG_FAILURE_POLICY
        See Also:
        Constant Field Values
    • Constructor Detail

      • TestNGOptions

        @Inject
        public TestNGOptions​(ProjectLayout projectLayout)
    • Method Detail

      • copyFrom

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

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

        @Internal
        protected java.io.File getProjectDir()
      • suites

        public void suites​(java.io.File... suiteFiles)
        Add suite files by File objects.
      • getSuites

        public java.util.List<java.io.File> getSuites​(java.io.File testSuitesDir)
      • includeGroups

        public TestNGOptions includeGroups​(java.lang.String... includeGroups)
      • excludeGroups

        public TestNGOptions excludeGroups​(java.lang.String... excludeGroups)
      • useDefaultListeners

        public TestNGOptions useDefaultListeners()
      • useDefaultListeners

        public TestNGOptions useDefaultListeners​(boolean useDefaultListeners)
      • propertyMissing

        public java.lang.Object propertyMissing​(java.lang.String name)
      • methodMissing

        public java.lang.Object methodMissing​(java.lang.String name,
                                              java.lang.Object args)
      • getOutputDirectory

        @OutputDirectory
        public java.io.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​(java.io.File outputDirectory)
      • getIncludeGroups

        @Input
        public java.util.Set<java.lang.String> getIncludeGroups()
        The set of groups to run.
      • setIncludeGroups

        public void setIncludeGroups​(java.util.Set<java.lang.String> includeGroups)
      • getExcludeGroups

        @Input
        public java.util.Set<java.lang.String> getExcludeGroups()
        The set of groups to exclude.
      • setExcludeGroups

        public void setExcludeGroups​(java.util.Set<java.lang.String> excludeGroups)
      • getConfigFailurePolicy

        @Internal
        public java.lang.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​(java.lang.String configFailurePolicy)
      • getListeners

        @Internal
        public java.util.Set<java.lang.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'
             }
         }
         
      • setListeners

        public void setListeners​(java.util.Set<java.lang.String> listeners)
      • getParallel

        @Nullable
        @Internal
        public java.lang.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​(java.lang.String parallel)
      • getThreadCount

        @Internal
        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)
      • getSuiteThreadPoolSize

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

        @Internal
        public boolean getUseDefaultListeners()
      • getThreadPoolFactoryClass

        @Internal
        @Incubating
        public java.lang.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.
      • setUseDefaultListeners

        public void setUseDefaultListeners​(boolean useDefaultListeners)
      • setThreadPoolFactoryClass

        @Incubating
        public void setThreadPoolFactoryClass​(java.lang.String threadPoolFactoryClass)
        Sets a custom threadPoolExecutorFactory class. This should be a fully qualified class name and the class should implement org.testng.IExecutorFactory More details in https://github.com/testng-team/testng/pull/2042 Requires TestNG 7.0 or higher
        Since:
        8.7
      • getSuiteName

        @Internal
        public java.lang.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​(java.lang.String suiteName)
      • getTestName

        @Internal
        public java.lang.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​(java.lang.String testName)
      • getSuiteXmlFiles

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

        public void setSuiteXmlFiles​(java.util.List<java.io.File> suiteXmlFiles)
      • getPreserveOrder

        @Internal
        public boolean getPreserveOrder()
      • 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.
      • setPreserveOrder

        public void setPreserveOrder​(boolean preserveOrder)
      • getGroupByInstances

        @Internal
        public boolean getGroupByInstances()
      • 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.
      • setGroupByInstances

        public void setGroupByInstances​(boolean groupByInstances)
      • getSuiteXml

        @Input
        @Optional
        protected java.lang.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 java.io.StringWriter getSuiteXmlWriter()
      • setSuiteXmlWriter

        public void setSuiteXmlWriter​(java.io.StringWriter suiteXmlWriter)
      • setSuiteXmlBuilder

        public void setSuiteXmlBuilder​(MarkupBuilder suiteXmlBuilder)