Friday, July 31, 2015

Create Parameterized Test Service with Jenkins


Introduction

This article describe how to create a Jenkins Project that run parameterized test case with specified browsers/cases parameter.

In this way, anyone who use Win 8.1 and can access the Jenkins web page can simply download win_folder, run *.bat to start selenium standalone, then run Jenkins Job and see the test cases run on hes/her screen.

NOTE: The method only works with Remote WebDriver, Jenkins has problem to run local driver directly.

Pre-Request

Use Remote Webdriver in Selenium

Create Parameterized Test Case

Install Jenkins on Ubuntu 14.04

Steps

There are quite a few steps,

0. update mode of log file

Change mode of SeleniumTest/log/test.log so Jenkins can access it.

# go to SeleniumTest/log
cd log
# chmod so Jenkins can write to test.log
chmod 666 test.log


1. Create custom test task

To run rake test with specified file set, we need to write a custom task,
run
rails g task test

to generate task file then modify it as

test.rake


2. Create Jenkins Job

Please refer to
online demo

and
content of jenkins project

3. Run Jenkins Job

Assume I use win 8.1, have installed required browsers, downloaded the win_folder and run the *.bat as needed, then I can run Jenkins job as below:

(please ignore the music, just for replce my original audio whitch contains lots of noise)


online demo

In the demo above, parameterized_with_env_test.rb will run on all specified browsers, remote_webdriver_test.rb will run on browsers written in test case.

References

How to generate rake task

Rake Task to Run a Custom Group of Tests

Rake::TestTask Document


Running selenium tests in ruby with Jenkins

No comments:

Post a Comment