Cucumber Browser Testing with MediaWiki Gems

with an inspiration from http://www.mediawiki.org/wiki/Quality_Assurance/Browser_testing(Thanks to @chris_mcmahon) I started setting up Cucumber an 'Acceptance Test Driven Development' which seems to use plain English to write tests.
Cucumber is a Ruby gem, and there are several configurations to be done in order to make tests work.

Being a novice to Ruby, Gems, Cucumber etc, it took me a while to figure out the setting up process.

Thankfully, mediawiki provides some gems which you can use to achive this.

Setup Ruby in Windows.

In Windows, we can download ruby from http://rubyinstaller.org/downloads/ and need to select version 1.9.3. Version 2.0.0 and above does not seem to work/compatible with the rest.
Set the Path environment variable to C:\Ruby193
Make sure to update the RubyGems software to version 2.3.0 by running
gem update --system 2.3.0  (or probably you leave it as it is without updating. I encountered a problem where you cannot install gems with version 2.3.0 due to SSL certificate issue)

You can verify the version of RubyGems using gem -v and version of ruby by ruby -v commands
After that we need to install a series of gems to run our tests.

Gems required
  • Bundler
  • mediawiki_selenium 
  • Devkit 
Download devkit from DevKit-tdm-32-4.5.2-20111229-1559-sfx.exe which is compatible with Ruby 1.9.3
Run following commands to setup devkit

  • ruby dk.rb init 
  • ruby dk.rb install

Install Bundler gem using gem install bundler
Then install mediawiki selenium driver using gem install mediawiki_selenium

Above steps should install required gems to the system including Cucumber. We do not need to install Cucumber gem or its dependencies explicitly. If it complains above missing dependencies run bundle install which will install required dependencies automatically

Then we need to download Cucumber tests already written in mediswiki
git clone https://gerrit.wikimedia.org/r/p/mediawiki/extensions/VisualEditor.git

We need to create some accounts for wiki, git and gerret as described in the following wiki page http://www.mediawiki.org/wiki/Quality_Assurance/Browser_testing/Setup_instructions

Then in the tests root folder (G:\WikiTests\VisualEditor\modules\ve-mw\tests\browser) we need to create a GemFile to add our dependancies
run bundle init  which will create a sample Gemfile. Add following dependency to the content

gem 'mediawiki_selenium', '~> 0.4.1'

Before running tests following environment variables need to be set
  • MEDIAWIKI_USER=xxxxxxx
  • MEDIAWIKI_API_URL=http://en.wikipedia.beta.wmflabs.org/w/api.php
  • MEDIAWIKI_URL=http://en.wikipedia.beta.wmflabs.org/wiki/
In your test folder, you get a folder called 'features' which contain all Cucumber tests, to run the test use following command

bundle exec cucumber features/links.feature

To run individul tests 

cucumber features/authenticate_user.feature:44 --format html > features.html
will run the scenario defined at line 44 of the authenticate_user feature, format it asHTML and pipe it to the features.html file for viewing in a browser.

No comments:

Post a Comment