/sample-web-testing

Sample of business-oriented executable specifications in end-to-end web testing world. Based on ruby/cucumber/watir/watirsome/rspec-expectation technologies.

Primary LanguageRuby

sample-web-testing

Overview

There is a sample of business-oriented tests as they should be. Tests are written in a declarative manner, they interact with page elements as an real user does and should be consider as a last source of project specifications. No duplicated testcases in any other separated source - all specifications should be placed under features repository.

The framework is written in Ruby and used such extensions:

  • cucumber - a collaboration tool with executive specs;
  • watir - most popular framework to interact with browser elements (built on top of WebDriver interface);
  • watirsome - page-object pattern implementation for watir framework;
  • rspec-expectations - lib from popular BDD framework which lets a describing expressions of expected outcomes on an object in an example.

Slides

Slides related to the project are available here.

Website sample

As a website sample I use http://automationpractice.com. It's a full featured e-commerce website simulator.

We would test product selection and making order there.

website sample

Test structure

├── config # storage of different config files
    ├── cucumber.yml # cucumber profiles
    ├── settings.yml # storage for custom config data such as browser type or base url
├── features # storage of test scenarios
    ├── lib # custom libs
        ├── helper.rb # storage of basic helper methods
        ├── page.rb # abstract class for page object models
    ├── pages # implementations of page object models
    ├── steps # storage of test step definitions
    ├── support # storage of cucumber env files and hooks preloaded for every test run
├── report.html # auto-generated html-report

Preparation

Installing Ruby

The framework requires Ruby version 2.4.1. The simplest way to manage ruby version is using rbenv

Installing rbenv on OS X systems

$ brew update
$ brew install rbenv
$ brew install ruby-build
$ rbenv init # and follow instructions from console output
$ rbenv install -l # list all available for installation ruby versions
$ rbenv install 2.4.1

(for Linux distributions - follow official guide)

After navigation to the project root directory, rbenv will recognize specified ruby version in .ruby-version file and switch on it. To check the its success, perform in console:

$ rbenv version
2.4.1 (set by /Users/<username>/gems-ui-test/.ruby-version)

If you see output like this - everything is fine.

Installing Ruby gems

I recommend to use bundler to manage Ruby gems. First of all, you're need to install bundler gem itself:

gem install bundler

After this, you can use bundler to manage all other gems for the project:

bundler install

Now, you are ready to run our samples of business-oriented tests.

Run features

To run features, go to the project dir in console and perform:

bundle exec cucumber

Nota bene: we specify bundle exec before actual ruby command to be sure that will be used proper version of the gem (specified in Gemfile)

It will run scenarios described in sample_shopping_declarative.feature due to default cucumber setting. The result will be shown in console. Due to default setting for this project, cucumber will also duplicate results in report.html file. You can learn more about how to run specific feature/scenario in cucumber wiki. Don't forget - cucumber profiles and tags gives additional abilities for test running.

So, enjoy your testing! Feel free to report an github issue if you have any questions.

TODO

  • add CI
  • add rubycop