Running mobile Silk4J tests in parallel with Jenkins

Micro Focus Expert
Micro Focus Expert
2 0 1,125

In Running Silk4J tests from Jenkins, we have outlined how you can easily run your Silk4J tests from Jenkins. Now we are taking this a step forward, into the mobile world. We will show how you can configure Jenkins to build and run the Silk4J tests of your mobile app, including running these tests on multiple devices in parallel.


To perform the actions described in this blog post, the following software is required:

  • Silk4J 17.5 or later.
  • Jenkins.
  • Git/SVN.

We will assume that you already have a Silk4J project and some tests for your mobile application. If this is not the case, check out the following blog posts on how to easily get started with mobile testing for Android and iOS:

For this demo, we have recorded a couple of steps in the InsuranceHybrid app, so that we can simply reuse the tests both for Android and iOS. The following image shows the recorded test:

Source control

To collaborate with other testers and to allow Jenkins to access our tests, we will use a source control system. We will use a local Git repository as everything we need is running on the local machine. Obviously you can use your preferred source control system instead.

Note: In Eclipse, you can use Team --> Share project --> Git --> Create repository to easily create a new local Git repository for your Silk4J project.


We will use Ant and JUnit for running the tests, so we will just extend the auto-generated build.xml file that Silk4J creates for each new project.

Note: If you do not use the lib folder of your Silk4J project and you want to use Git as the source control management, as we do in the remainder of this blog post, make the following two changes to the build.xml:


With these changes, your build works even if the lib folder is not present. For additional information, see the Git FAQ.

Add a new target runTests to the build.xml that will simply run all JUnit tests in the project and generate an XML report:

<target name="runTests" depends="compile"> <junit fork="yes" printsummary="true" showoutput="true"> <classpath> <path refid="project.classpath" /> <fileset dir="${output}" includes="*.jar" /> </classpath> <batchtest> <zipfileset src="${output}/tests.jar" includes="**/*.class" /> </batchtest> <formatter type="xml" /> <formatter type="plain" usefile="false" /> </junit> </target>

Jenkins Configuration

First, we need to make sure that Jenkins will run our tests with an account that is not the Windows SYSTEM account, as this would cause problems with the Open Agent. For our simple scenario we'll just start the Jenkins node manually in as the user account with which we are currently logged in.

To do so, add a new node in Jenkins by navigating to Manage Jenkins >Manage Nodes > New Node. Remember the name that you give this node as we'll need that later. Make sure to select the Launch agent via Java Web Start launch method as this will allow us to start the node manually:

After having added the node, select it in the nodes list in Manage Jenkins > Manage Nodes, and click Launch. This will download a JNLP file which you can simply run to start the node:

Jenkins Job

Next, we will create a new Jenkins job that will actually compile and run our tests.

Check the This project is parameterized check box on the next page, and define a new parameter called silktest.configurationName:


We will use the new parameter to control which device, or family of devices the tests should be executed on. We have configured platformName=Android; as the default value, so when we execute the job the first available Android device is used. If we run the job multiple times in parallel, Silk Test will always choose another device as long as devices are available. For additional information on the connection string, refer to the Silk4J Help.

Check the Execute concurrent builds if necessary check box, and define which nodes should be used for running the job. Use the name of the node created before as the Label Expression to make sure that this job will run on that particular node:


Note: To enable Silk Test to allow parallel test execution on multiple devices, the environment variable SILKTEST_ENABLE_PARALLEL_TESTING has to be set to true.

Next, define from where Jenkins should check out the project. In our case, this is a local Git repository which has been created in Eclipse:

Under Build, define a build step that will run the runTests Ant task:

And finally, add a post-build step to publish the JUnit test results to Jenkins. That way, the JUnit plugin in Jenkins will know about success and failure of our tests and can visualize that:

Now run that job using Build with parameters:

In Jenkins, you can view the progress of running the tests on the Console Output page:

Also, if you check out the Silk Test Information Service page on http://localhost:22901 or wherever your mobile devices are connected, you can watch a live screen cast of the running tests:

After the tests have finished you can check out the JUnit test results in Jenkins:

If you now start two such builds in parallel, Silk Test will pick up the first Android device for the first run, and the second device, if available, for the second run. If no second device is available, the test will fail:

Advanced device management

That is pretty cool! But what if you need more sophisticated capabilities, like running the tests on different mobile devices, or ensuring that certain tests always run on the same device or family of devices? You can achieve all of this with Silk Test and Jenkins, but it is much more convenient to use Silk Centrals Device Cloud capabilities together with Silk Test. Check out the Silk Central documentation for details.

The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.