Tuesday, August 12, 2014

Continues Integration – how to run siesta via Jenkins?

As you’ve seen in the previous post (Running siesta from a remote computer), you can run siesta tests remotely. Moreover, you can create a Jenkins job which will run those tests for you, and will indicate for any failed test.

In order to do that, you need first to complete the setup in the “Running siesta from a remote computer” post, so that you’ll have server and client configuration.

After getting that stage done, you’ll need to:
  1.  Install siesta on your Jenkins machine.
  2.  Install java on your Jenkins machine.
  3.  Validate that you can run the webdriver commands from your Jenkins machine. it means that from the path where siesta is installed on your Jenkins, you need to go to the “bin” directory and run from there a test with webdriver. for example:

# webdriver http://IP/siestaTests --include=MytestFile.t.js --host YourHostName --port 4444 --browser=ie --report-format=JUnit --report-file=MytestFile_log_

(If you experience any problems, please refer to the “Running siesta from a remote computer” post).

After you successfully managed to run the webdriver command, you can start to configure the Jenkins job:

1. Access your Jenkins server -> click on “new item” -> choose the “Build a free style software project” option, and give the job a name.

2. In the job configuration window (which will open as you click on the “ok” button), check the “This build is parameterized” option.

3. The parameters are used for your comfort only, and they are NOT a must. I recommend configuring them so that you can run the same build with different options (such as different browsers or different clients) without needing to create a new job for each option.

4. You’ll need to configure 5 parameters, and in order to do so click on “Add parameter” button under the option you checked in step 2.

·         Parameter type:  Text Parameter
Default value: insert here your client http address, which is the URL of your siesta GUI.
·         Parameter type:  Choice
Choices: insert here the browsers you want to test on, with a separation of a new line between each.
·         Parameter type:  String Parameter
Default value: insert here your server IP address, which is the machine you want the tests to run against.
·         Parameter type:  String Parameter
Name: PORT
Default value: insert here the webderiver server port, which is 4444 by default.
·         Parameter type:  String Parameter
Default value: insert here the path of the tests you want to run. You can remove this parameter and just run all the tests. If you are using this parameter, note that the path you give here is relative to the index.js file.

5. Now add a very simple shell script which will run the webdriver command on your Jenkins. in order to do that you need to click on “Add build step” under the Build section on your job configuration.

6. Choose “execute shell” and in the window that opens, insert the following:

export JAVA_HOME={the path of your java installation, i.e. /opt/java/jdk1.7.0_51}
export PATH=$JAVA_HOME/bin:$PATH
{full location of siesta webdriver, i.e. /var/siesta/bin/webdriver } ${ CLIENT_NAME } --report-format JUnit --report-file-prefix junit- --browser ${BROWSER} --host ${ SERVER_NAME } --port ${ PORT } --no-color --include=${ TESTS_TO_INCLUDE }

7. Now all that’s left is to get the tests results in Jenkins. to do that go to “Post-build Actions” and click on “Add post-build action”. Choose “Publish JUnit test result report” and in the “Test report XMLs” field insert “junit-*”.

8. Click on “save”.

That’s it! All configuration is done, and from now on you can use siesta tests as a part of the continues integration process, by running the siesta-tests build before/after other builds.

No comments:

Post a Comment