-
Notifications
You must be signed in to change notification settings - Fork 11
Gradle
Selenified is designed to work seamlessly in your gradle project, whether it is a new one, or existing one. Ensure you are using the standard gradle project setup.
First thing to do is to add Selenified as a dependency. Update your build.gradle
file to include (or add the testCompile
line to your current dependencies).
dependencies {
testCompile group: 'com.coveros', name: 'selenified', version: '3.0.4'
}
If following the setup indicated, you'll need to add a task to execute your tests. Update your build.gradle
file to include
task selenified(type:Test) {
useTestNG() {
systemProperties System.getProperties()
}
}
Then from the command line run
gradle selenified
If everything is set up properly, no runtime parameters are required, but many can be provided to change and optimize runtime performance. This can and should be done by adding configuration for the selenified
task. Several options exist to change how your tests are run.
Configuration | Description |
---|---|
threads |
how many tests you want to run in parallel |
logging |
how much verbosity in the logging is desired |
listener |
if you want to loop through multiple browsers for the same test, use the custom Selenified Transformer
|
groups |
what tests do you want to include or exclude in the test run based on the provided groups tagging |
Then these variables can be set up and configured in the selenified block.
task selenified(type: Test) {
def threads = System.getProperty("threads") ? System.getProperty("threads") : 5
systemProperties System.getProperties()
useTestNG() {
useDefaultListeners = true
if (System.getProperty("groups.include") != null) {
includeGroups System.getProperty("groups.include")
}
if (System.hasProperty("groups.exclude") != null) {
excludeGroups System.getProperty("groups.exclude")
}
}
testLogging {
showStandardStreams = true
exceptionFormat = 'full'
}
options {
listeners.add("com.coveros.selenified.utilities.Transformer")
parallel = 'methods'
threadCount = threads
}
}
To override these parameters from the command-line, you'll want to pass in the variable name proceeded by a -D
and set the desired value. For example, to change threading from the default 5 to 2, the below command would be used:
gradle selenified -Dthreads=2
plugins {
id 'java'
}
group 'com.coveros'
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
testCompile group: 'com.coveros', name: 'selenified', version: '3.0.4'
}
task selenified(type: Test) {
def threads = System.getProperty("threads") ? System.getProperty("threads") : 5
systemProperties System.getProperties()
useTestNG() {
useDefaultListeners = true
if (System.getProperty("groups.include") != null) {
includeGroups System.getProperty("groups.include")
}
if (System.hasProperty("groups.exclude") != null) {
excludeGroups System.getProperty("groups.exclude")
}
}
testLogging {
showStandardStreams = true
exceptionFormat = 'full'
}
options {
listeners.add("com.coveros.selenified.utilities.Transformer")
parallel = 'methods'
threadCount = threads
}
}
A sample gradle project can be found here
© Coveros 2019