Class TestNgOperation
- Since:
- 1.0
- Author:
- Erik C. Thauvin
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Failure Policiesstatic enum
Parallel Mechanisms -
Field Summary
Fields inherited from class rife.bld.operations.TestOperation
testToolOptions_
Fields inherited from class rife.bld.operations.AbstractProcessOperation
classpath_, DEFAULT_JAVA_TOOL, errorProcessor_, errorProcessorThread_, javaOptions_, javaTool_, mainClass_, module_, modulePath_, outputProcessor_, outputProcessorThread_, process_, successful_, workDirectory_
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionalwaysRunListeners
(Boolean isAlwaysRunListeners) Should Method Invocation Listeners be run even for skipped methods.dataProviderThreadCount
(int count) This sets the default maximum number of threads to use for data providers when running tests in parallel.dependencyInjectorFactory
(String injectorFactory) The dependency injector factory implementation that TestNG should use.The directory where the reports will be generatedThe directory where the reports will be generatedThe directory where the reports will be generatedexcludeGroups
(String... group) The list of groups you want to be excluded from this run.excludeGroups
(Collection<String> group) The list of groups you want to be excluded from this run.void
execute()
Part of theexecute
operation, constructs the command list to use for building the process.Whether TestNG should continue to execute the remaining tests in the suite or skip them if in a@Before*
method.failWhenEverythingSkipped
(Boolean isFailAllSkipped) Should TestNG fail execution if all tests were skipped and nothing was run.fromProject
(BaseProject project) Configures theBaseProject
.generateResultsPerSuite
(Boolean resultsPerSuite) Should TestNG generate results on a per-suite basis by creating a subdirectory for each suite and dumping results into it.The list of groups you want to run.groups
(Collection<String> group) The list of groups you want to run.ignoreMissedTestName
(Boolean isIgnoreMissedTestNames) Ignore missed test names given bytestNames
and continue to run existing tests, if any.includeAllDataDrivenTestsWhenSkipping
(Boolean isIncludeDrivenTestsWhenSkipping) Should TestNG report all iterations of a data driven test as individual skips, in-case of upstream failures.Enables or disables the JUnit mode.The list of.class
files or list of class names implementingITestListener
orISuiteListener
listener
(Collection<String> listener) The list of.class
files or list of class names implementingITestListener
orISuiteListener
listenerComparator
(String listenerComparator) An implementation ofListenerComparator
that will be used by TestNG to determine order of execution for listeners.listenerFactory
(String listenerFactory) The factory used to create TestNG listeners.log
(int level) Set the Level of verbosity.methods()
Returns the methods to run.Lets you specify individual methods to run.methods
(Collection<String> method) Lets you specify individual methods to run.methodSelectors
(String... selector) Specifies the list of.class
files or class names implementingIMethodSelector
.methodSelectors
(Collection<String> selector) Specifies the list of.class
files or class names implementingIMethodSelector
.Mixed mode autodetects the type of current test and run it with appropriate runner.objectFactory
(String... factory) The list of.class
files or class names implementingITestRunnerFactory
.objectFactory
(Collection<String> factory) The list of.class
files or class names implementingITestRunnerFactory
.options()
Returns the run options.overrideIncludedMethods
(String... method) The list of fully qualified class names of listeners that should be skipped from being wired in via Service Loaders.overrideIncludedMethods
(Collection<String> method) The list of fully qualified class names of listeners that should be skipped from being wired in via Service Loaders.packages()
Returns the suite packages to run.The list of packages to include in this test.packages
(Collection<String> name) The list of packages to include in this test.parallel
(TestNgOperation.Parallel mechanism) If specified, sets the default mechanism used to determine how to use parallel threads when running tests.port
(int port) Specifies the port number.propagateDataProviderFailureAsTestFailure
(Boolean isPropagateDataProviderFailure) Should TestNG consider failures in Data Providers as test failures.Specifies the extended configuration for custom report listener.shareThreadPoolForDataProviders
(boolean shareThreadPoolForDataProviders) Should TestNG use a global Shared ThreadPool (At suite level) for running data providers.The directories where your javadoc annotated test sources are.The directories where your javadoc annotated test sources are.The directories where your javadoc annotated test sources are.sourceDir
(Collection<String> directory) The directories where your javadoc annotated test sources are.sourceDirFiles
(Collection<File> directory) The directories where your javadoc annotated test sources are.sourceDirPaths
(Collection<Path> directory) The directories where your javadoc annotated test sources are.spiListenersToSkip
(String... listenerToSkip) Specifies the List of fully qualified class names of listeners that should be skipped from being wired in via Service Loaders.spiListenersToSkip
(Collection<String> listenerToSkip) Specifies the List of fully qualified class names of listeners that should be skipped from being wired in via Service Loaders.This specifies the default name of the test suite, if not specified in the suite definition file or source code.suites()
Returns the suites to run.Specifies the suites to run.suites
(Collection<String> suite) Specifies the suites to run.suiteThreadPoolSize
(int poolSize) Specifies the size of the thread pool to use to run suites.Specifies the list of class files.testClass
(Collection<String> aClass) Specifies the list of class files.Returns the classpath entries used for running tests.testClasspath
(String... entry) Specifies the classpath entries used to run tests.testClasspath
(Collection<String> entry) Specifies the classpath entries used to run tests.Specifies a jar file that contains test classes.This specifies the default name of test, if not specified in the suite definition file or source code.Only tests defined in a<test>
tag matching one of these names will be run.testNames
(Collection<String> name) Only tests defined in a<test>
tag matching one of these names will be run.testRunFactory
(String factory) Specifies the factory used to create tests.threadCount
(int count) This sets the default maximum number of threads to use for running tests in parallel.threadPoolFactoryClass
(String factoryClass) Specifies the thread pool executor factory implementation that TestNG should use.useDefaultListeners
(Boolean isDefaultListener) Whether to use the default listenersuseGlobalThreadPool
(boolean useGlobalThreadPool) Should TestNG use a global Shared ThreadPool (At suite level) for running regular and data driven tests.verbose
(int level) Set the Level of verbosity.xmlPathInJar
(File path) This attribute should contain the path to a valid XML file inside the test jar (e.g.xmlPathInJar
(String path) This attribute should contain the path to a valid XML file inside the test jar (e.g.xmlPathInJar
(Path path) This attribute should contain the path to a valid XML file inside the test jar (e.g.Methods inherited from class rife.bld.operations.TestOperation
createTestToolOptions, testToolOptions, testToolOptions, testToolOptions
Methods inherited from class rife.bld.operations.AbstractProcessOperation
classpath, classpath, classpath, errorProcessor, errorProcessor, executeStartProcess, javaOptions, javaOptions, javaTool, javaTool, mainClass, mainClass, module, module, modulePath, modulePath, modulePath, outputProcessor, outputProcessor, process, workDirectory, workDirectory
Methods inherited from class rife.bld.operations.AbstractOperation
executeOnce, executeOnce, silent, silent
-
Constructor Details
-
TestNgOperation
public TestNgOperation()
-
-
Method Details
-
alwaysRunListeners
Should Method Invocation Listeners be run even for skipped methods.Default is
true
- Parameters:
isAlwaysRunListeners
-true
orfalse
- Returns:
- this operation instance
-
dataProviderThreadCount
This sets the default maximum number of threads to use for data providers when running tests in parallel. It will only take effect if the parallel mode has been selected (for example,with theparallel
option). This can be overridden in the suite definition.- Parameters:
count
- the count- Returns:
- this operation instance
-
dependencyInjectorFactory
The dependency injector factory implementation that TestNG should use.- Parameters:
injectorFactory
- the injector factory- Returns:
- this operation instance
-
directory
The directory where the reports will be generatedDefault is
build/test-output
)- Parameters:
directoryPath
- the directory path- Returns:
- this operation instance
-
directory
The directory where the reports will be generatedDefault is
build/test-output
)- Parameters:
directoryPath
- the directory path- Returns:
- this operation instance
-
directory
The directory where the reports will be generatedDefault is
build/test-output
)- Parameters:
directoryPath
- the directory path- Returns:
- this operation instance
-
excludeGroups
The list of groups you want to be excluded from this run.- Parameters:
group
- one or more groups- Returns:
- this operation instance
- See Also:
-
excludeGroups
The list of groups you want to be excluded from this run.- Parameters:
group
- the list of groups- Returns:
- this operation instance
- See Also:
-
execute
- Overrides:
execute
in classAbstractProcessOperation<TestNgOperation>
- Throws:
IOException
InterruptedException
ExitStatusException
-
executeConstructProcessCommandList
Part of theexecute
operation, constructs the command list to use for building the process.- Overrides:
executeConstructProcessCommandList
in classTestOperation<TestNgOperation,
List<String>> - Returns:
- the command list
-
fromProject
Configures theBaseProject
.- Overrides:
fromProject
in classTestOperation<TestNgOperation,
List<String>> - Parameters:
project
- the project- Returns:
- this operation instance
-
failWhenEverythingSkipped
Should TestNG fail execution if all tests were skipped and nothing was run.- Parameters:
isFailAllSkipped
-true
orfalse
- Returns:
- this operation instance
-
failurePolicy
Whether TestNG should continue to execute the remaining tests in the suite or skip them if in a@Before*
method.- Parameters:
policy
- the policy- Returns:
- this operation instance
-
generateResultsPerSuite
Should TestNG generate results on a per-suite basis by creating a subdirectory for each suite and dumping results into it.Default is
.false
- Parameters:
resultsPerSuite
-true
orfalse
- Returns:
- this operation instance
-
groups
The list of groups you want to run.For example:
"windows", "linux", "regression
- Parameters:
group
- one or more groups- Returns:
- this operation instance
- See Also:
-
groups
The list of groups you want to run.For example:
"windows", "linux", "regression
- Parameters:
group
- the list of groups- Returns:
- this operation instance
- See Also:
-
ignoreMissedTestName
Ignore missed test names given bytestNames
and continue to run existing tests, if any.Default is
false
- Parameters:
isIgnoreMissedTestNames
-true
orfalse
- Returns:
- this operation instance
-
includeAllDataDrivenTestsWhenSkipping
public TestNgOperation includeAllDataDrivenTestsWhenSkipping(Boolean isIncludeDrivenTestsWhenSkipping) Should TestNG report all iterations of a data driven test as individual skips, in-case of upstream failures.Default is
false
- Parameters:
isIncludeDrivenTestsWhenSkipping
-true
orfalse
- Returns:
- this operation instance
-
jUnit
Enables or disables the JUnit mode.Default is
false
- Parameters:
isJunit
-true
orfalse
- Returns:
- this operation instance
-
listener
The list of.class
files or list of class names implementingITestListener
orISuiteListener
- Parameters:
listener
- one or more listeners- Returns:
- this operation instance
- See Also:
-
listener
The list of.class
files or list of class names implementingITestListener
orISuiteListener
- Parameters:
listener
- the list of listeners- Returns:
- this operation instance
- See Also:
-
listenerComparator
An implementation ofListenerComparator
that will be used by TestNG to determine order of execution for listeners.- Parameters:
listenerComparator
- the listener comparator- Returns:
- this operation instance
-
listenerFactory
The factory used to create TestNG listeners.- Parameters:
listenerFactory
- the listener factory- Returns:
- this operation instance
-
log
Set the Level of verbosity.- Parameters:
level
- the level- Returns:
- this operation instance
- See Also:
-
methodSelectors
Specifies the list of.class
files or class names implementingIMethodSelector
.For example:
"com.example.Selector1:3", "com.example.Selector2:2"
- Parameters:
selector
- one or more selectors- Returns:
- this operation instance
- See Also:
-
methodSelectors
Specifies the list of.class
files or class names implementingIMethodSelector
.For example:
"com.example.Selector1:3", "com.example.Selector2:2"
- Parameters:
selector
- the list of selectors- Returns:
- this operation instance
- See Also:
-
methods
Lets you specify individual methods to run.For example:
"com.example.Foo.f1", "com.example.Bar.f2"
- Parameters:
method
- one or more methods- Returns:
- this operation instance
- See Also:
-
methods
Lets you specify individual methods to run.For example:
"com.example.Foo.f1", "com.example.Bar.f2"
- Parameters:
method
- the list of methods- Returns:
- this operation instance
- See Also:
-
methods
Returns the methods to run.- Returns:
- the set of methods
-
mixed
Mixed mode autodetects the type of current test and run it with appropriate runner.Default is
false
- Parameters:
isMixed
-true
orfalse
- Returns:
- this operation instance
-
objectFactory
The list of.class
files or class names implementingITestRunnerFactory
.A fully qualified class name that implements
org.testng.ITestObjectFactory
which can be used to create test class and listener instances.- Parameters:
factory
- one or more factory- Returns:
- this operation instance
- See Also:
-
objectFactory
The list of.class
files or class names implementingITestRunnerFactory
.A fully qualified class name that implements
org.testng.ITestObjectFactory
which can be used to create test class and listener instances.- Parameters:
factory
- the list of factories- Returns:
- this operation instance
- See Also:
-
options
Returns the run options.- Returns:
- the map of run options
-
overrideIncludedMethods
The list of fully qualified class names of listeners that should be skipped from being wired in via Service Loaders.- Parameters:
method
- one or more methods- Returns:
- this operation instance
- See Also:
-
overrideIncludedMethods
The list of fully qualified class names of listeners that should be skipped from being wired in via Service Loaders.- Parameters:
method
- the list of methods- Returns:
- this operation instance
- See Also:
-
packages
The list of packages to include in this test. If the package name ends with .* then subpackages are included too. Required if nosuites(String...suites)
specified.For example:
"com.example", "test.sample.*"
- Parameters:
name
- one or more names- Returns:
- this operation instance
- See Also:
-
packages
The list of packages to include in this test. If the package name ends with .* then subpackages are included too. Required if nosuites(String...suites)
specified.For example:
"com.example", "test.sample.*"
- Parameters:
name
- the list of names- Returns:
- this operation instance
- See Also:
-
packages
Returns the suite packages to run.- Returns:
- the set of packages
-
parallel
If specified, sets the default mechanism used to determine how to use parallel threads when running tests. If not set, default mechanism is not to use parallel threads at all. This can be overridden in the suite definition.- Parameters:
mechanism
- the mechanism- Returns:
- this operation instance
- See Also:
-
port
Specifies the port number.- Parameters:
port
- the port- Returns:
- this operation instance
-
propagateDataProviderFailureAsTestFailure
public TestNgOperation propagateDataProviderFailureAsTestFailure(Boolean isPropagateDataProviderFailure) Should TestNG consider failures in Data Providers as test failures.Default is
false
- Parameters:
isPropagateDataProviderFailure
-true
orfalse
- Returns:
- this operation instance
-
reporter
Specifies the extended configuration for custom report listener.- Parameters:
reporter
- the reporter- Returns:
- this operation instance
-
sourceDir
The directories where your javadoc annotated test sources are. This option is only necessary if you are using javadoc type annotations. (e.g."src/test"
or"src/test/org/testng/eclipse-plugin", "src/test/org/testng/testng"
).- Parameters:
directory
- one or more directories- Returns:
- this operation instance
- See Also:
-
sourceDir
The directories where your javadoc annotated test sources are. This option is only necessary if you are using javadoc type annotations. (e.g."src/test"
or"src/test/org/testng/eclipse-plugin", "src/test/org/testng/testng"
).- Parameters:
directory
- one or more directories- Returns:
- this operation instance
- See Also:
-
sourceDir
The directories where your javadoc annotated test sources are. This option is only necessary if you are using javadoc type annotations. (e.g."src/test"
or"src/test/org/testng/eclipse-plugin", "src/test/org/testng/testng"
).- Parameters:
directory
- one or more directories- Returns:
- this operation instance
- See Also:
-
sourceDir
The directories where your javadoc annotated test sources are. This option is only necessary if you are using javadoc type annotations. (e.g."src/test"
or"src/test/org/testng/eclipse-plugin", "src/test/org/testng/testng"
).- Parameters:
directory
- the list of directories- Returns:
- this operation instance
- See Also:
-
sourceDirFiles
The directories where your javadoc annotated test sources are. This option is only necessary if you are using javadoc type annotations. (e.g."src/test"
or"src/test/org/testng/eclipse-plugin", "src/test/org/testng/testng"
).- Parameters:
directory
- the list of directories- Returns:
- this operation instance
- See Also:
-
sourceDirPaths
The directories where your javadoc annotated test sources are. This option is only necessary if you are using javadoc type annotations. (e.g."src/test"
or"src/test/org/testng/eclipse-plugin", "src/test/org/testng/testng"
).- Parameters:
directory
- the list of directories- Returns:
- this operation instance
- See Also:
-
spiListenersToSkip
Specifies the List of fully qualified class names of listeners that should be skipped from being wired in via Service Loaders.- Parameters:
listenerToSkip
- the listeners to skip- Returns:
- this operation instance
- See Also:
-
spiListenersToSkip
Specifies the List of fully qualified class names of listeners that should be skipped from being wired in via Service Loaders.- Parameters:
listenerToSkip
- the listeners to skip- Returns:
- this operation instance
- See Also:
-
suiteName
This specifies the default name of the test suite, if not specified in the suite definition file or source code. This option is ignored if thesuite.xml
file or the source code specifies a different suite name.- Parameters:
name
- the name- Returns:
- this operation instance
-
suiteThreadPoolSize
Specifies the size of the thread pool to use to run suites. Required if nopackages(String...)
specified.- Parameters:
poolSize
- the pool size- Returns:
- this operation instance
-
suites
Specifies the suites to run.For example:
"testng.xml", "testng2.xml"
- Parameters:
suite
- one or more suites- Returns:
- this operation instance
- See Also:
-
suites
Specifies the suites to run.For example:
"testng.xml", "testng2.xml"
- Parameters:
suite
- the list of suites- Returns:
- this operation instance
- See Also:
-
suites
Returns the suites to run.- Returns:
- the set of suites
-
testClass
Specifies the list of class files.For example:
"org.foo.Test1","org.foo.test2"
- Parameters:
aClass
- one or more classes- Returns:
- this operation instance
- See Also:
-
testClass
Specifies the list of class files.For example:
"org.foo.Test1","org.foo.test2"
- Parameters:
aClass
- the list of classes- Returns:
- this operation instance
- See Also:
-
testClasspath
Specifies the classpath entries used to run tests.- Parameters:
entry
- one or more entries- Returns:
- this operation instance
- See Also:
-
testClasspath
Specifies the classpath entries used to run tests.- Parameters:
entry
- the list of entries- Returns:
- this operation instance
- See Also:
-
testClasspath
Returns the classpath entries used for running tests.- Returns:
- the set of test classpath
-
testJar
Specifies a jar file that contains test classes. If atestng.xml
file is found at the root of that jar file, it will be used, otherwise, all the test classes found in this jar file will be considered test classes.- Parameters:
jar
- the jar- Returns:
- this operation instance
-
testName
This specifies the default name of test, if not specified in the suite definition file or source code. This option is ignored if thesuite.xml
file or the source code specifies a different test name.- Parameters:
name
- the name- Returns:
- this operation instance
-
testNames
Only tests defined in a<test>
tag matching one of these names will be run.- Parameters:
name
- one or more names- Returns:
- this operation instance
- See Also:
-
testNames
Only tests defined in a<test>
tag matching one of these names will be run.- Parameters:
name
- the list of names- Returns:
- this operation instance
- See Also:
-
testRunFactory
Specifies the factory used to create tests.- Parameters:
factory
- the factory- Returns:
- this operation instance
-
threadCount
This sets the default maximum number of threads to use for running tests in parallel. It will only take effect if the parallel mode has been selected (for example, with theparallel
option). This can be overridden in the suite definition.- Parameters:
count
- the count- Returns:
- this operation instance
-
threadPoolFactoryClass
Specifies the thread pool executor factory implementation that TestNG should use.- Parameters:
factoryClass
- the factory class- Returns:
- this operation instance
-
useDefaultListeners
Whether to use the default listenersDefault is
true
- Parameters:
isDefaultListener
-true
orfalse
- Returns:
- this operation instance
-
useGlobalThreadPool
Should TestNG use a global Shared ThreadPool (At suite level) for running regular and data driven tests.- Parameters:
useGlobalThreadPool
-true
orfalse
- Returns:
- this operation instance
-
verbose
Set the Level of verbosity.- Parameters:
level
- the level- Returns:
- this operation instance
- See Also:
-
xmlPathInJar
This attribute should contain the path to a valid XML file inside the test jar (e.g."resources/testng.xml"
). The default istestng.xml
, which means a file calledtestng.xml
at the root of the jar file. This option will be ignored unless a test jar is specified.- Parameters:
path
- the path- Returns:
- this operation instance
-
xmlPathInJar
This attribute should contain the path to a valid XML file inside the test jar (e.g."resources/testng.xml"
). The default istestng.xml
, which means a file calledtestng.xml
at the root of the jar file. This option will be ignored unless a test jar is specified.- Parameters:
path
- the path- Returns:
- this operation instance
-
xmlPathInJar
This attribute should contain the path to a valid XML file inside the test jar (e.g."resources/testng.xml"
). The default istestng.xml
, which means a file calledtestng.xml
at the root of the jar file. This option will be ignored unless a test jar is specified.- Parameters:
path
- the path- Returns:
- this operation instance
-