Got a question? Email us or reach out on LinkedIn
This project is to create a executable JAR file of the SaucelabsRunner class. Typically, this executable is run by a Jenkins job in which the Saucelabs Support plugin has been enabled.
Once Saucelabs is enabled in Jenkins and the desired Browser Type, Browser Version, and Platform (operating systems) have been selected, the environment variable SAUCE_ONDEMAND_BROWSERS is automatically set for the duration of the job.
When this JAR is executed, the SAUCE_ONDEMAND_BROWSERS environment variable is dynamically read and a PERL script is generated named parallel-exec.pl in the root of your Jenkins job which executed this runner.
The resulting PERL script is then able to concurrently run Maven instances of automated tests against any browser/version/platform version(s) selected in the Saucelabs Jenkins plugin. When the PERL script is executed the test results are output to the target/failsafe-reports-X (X = index of the number of browser/version/platform version(s) combinations you ran against.
This tool assumes you are using the core-microservice
The github issue tracker is only for bug reports and feature requests. Anything else, such as questions for help in using the library, should be emailed to our team.
- Maven 3.x
- Java 1.8
<dependency>
<groupId>com.pacificwebconsulting.runner</groupId>
<artifactId>runner-microservice</artifactId>
<version>1.0.x</version>
</dependency>
- Compile Saucelabs Runner via Jenkins Job
- Execute Saucelabs Runner JAR with SAUCE_ONDEMAND_BROWSERS environment variable set
- Generate PERL script named 'parallel-exec.pl'
- Run PERL script
- PERL script runs asynchronous Maven jobs
- Run tests via Maven
- Gather test results with TestNG Jenkins plugin
The following 2 fields must be defined by your Jenkins job and passed to PERL script in this order:
- Maven Profile (example: regression)
- Test Environment (example: pad-dev)
The following configuration must be included in your Profile in the POM.xml ${project.build.directory}/${test.results.dir}
<profile>
<id>regression</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${maven-failsafe-plugin.version}</version>
<executions>
<execution>
<id>regression-system-tests</id>
<goals>
<goal>integration-test</goal>
</goals>
<configuration>
<groups>regressionTest</groups>
<excludedGroups>inProgressTest,manualTest,acceptanceTest</excludedGroups>
<parallel>methods</parallel>
<parallelOptimized>true</parallelOptimized>
<threadCount>${default.thread.runners}</threadCount>
<includes>
<include>**/*Test.java</include>
<include>**/Test*.java</include>
</includes>
<reportsDirectory>${project.build.directory}/${test.results.dir}</reportsDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
The following sample is how to execute this runner JAR to produce the resulting .pl PERL file from Jenkins. Execution from Jenkins is suggested becaause the Saucelabs plugin automatically sets the SAUCE_ONDEMAND_BROWSERS environment variable which is mandatory.
Preconditions of this output are:
- Jenkins & Saucelabs Plugin setting SAUCE_ONDEMAND_BROWSERS environment variable
- Arg[0] MANDATORY Test Profile variable args sent on command line during execution
- Arg[1] MANDATORY Test Environment variable args sent on command line during execution
- Arg[2] OPTIONAL Browser Resolution variable args sent on command line during execution
- Arg[3] OPTIONAL File Path to resulting PERL file variable args sent on command line during execution
- Arg[4] OPTIONAL File Name to resulting PERL file variable args sent on command line during execution
java -cp "C:\Program Files (x86)\Jenkins\workspace\runner-microservice\target\runner-microservice-1.0.0-SNAPSHOT.jar" com.pwc.runner.SaucelabsRunner %Test_Profile% %Test_Environment%
"800x600", "1024x768", "1152x720", "1152x864", "1152x900", "1280x720", "1280x768", "1280x800", "1280x960", "1280x1024", "1366x768", "1376x1032", "1400x1050", "1440x900", "1600x900", "1600x1200", "1680x1050", "1920x1200", "1920x1440", "2048x1152", "2048x1536", "2360x1770"
#! perl -slw
use strict;
use Thread qw(yield async);
system("mvn clean install");
my $t0 = async{
`mvn install -Pacceptance -Dtest.env=pad-dev -Dbrowser="chrome" -Dplatform="Windows 10" -Dbrowser.version=45 -Dtest.results.dir=failsafe-reports-0`
};
my $t1 = async{
`mvn install -Pacceptance -Dtest.env=pad-dev -Dbrowser="firefox" -Dplatform="Windows 7" -Dbrowser.version=44 -Dtest.results.dir=failsafe-reports-1`
};
my $output0 = $t0->join;
my $output1 = $t1->join;
print for $output0;
print for $output1;
All test results are stored in multiple 'target/failsafe-reports-X' directories. In Jenkins, your Publish TestNG Results configuration settings must be modified with a wildcard since you will have multiple result XML files. This wildcard will be sure to combine all test results into a single TestNG test report.
IMPORTANT: Don't forget to add the configuration to your Maven profile to ensure the TestNG results are correctly reported
For example: **/testng-results.xml