Pages

Friday 5 April 2013

Running your test suite on a headless environment. #watir #testing #ci

This post was inspired by my last post. It included a snippet that has sparked a few questions from friends, so I thought I'd put together a post on what is, and what it does. 







Having your test suite use the headless gem allows you to run them in other headless environments, such as Jenkins/Hudson servers.










So, what is the headless gem and what does it do?


The headless gem is simply a wrapper for Xvfb. Xvfb allows applications that require a GUI to be run on a headless Linux machine. This is perfect should we want to run our WebDriver tests on a headless Jenkins server. This also means that should you have screenshot functionality in place (if not, it's really easy), it will still capture the page.


First things first


You'll need to install Xvfb and Firefox on to your Linux server (commands assume a Debian based OS):

sudo apt-get install xvfb

sudo apt-get install firefox


Then we install the headless gem:


gem install headless


Next, the code


Paste the following into your env.rb file



OK. I've done all that. Now what?


Now all you need to do is pass in the ENV variable at runtime in your preferred fashion. Personally, I'm a fan of setting my Watir specific environment variables in the cucumber.yml for Rake to pick up.


As always, if you found this post helpful, please share it. If you have any questions or insights on headless environments, please comment below or tweet me.


Photo source: Headless Man

No comments:

Post a Comment