Working with Cucumber Tests

 

Cucumber Tests

Cucumber is a software tool that computer programmers use for testing other software. It runs automated acceptance tests written in a behavior-driven development (BDD) style.
from Wikipedia

To begin working with Cucumber we started of looking at examples online and found a someone had asked a similar question on Stackoverflow :-).

This is one of the samples


@javascript
Feature: invitation acceptance
Scenario: accept invitation from admin
Given I have been invited by an admin
And I am on my acceptance form page
And I fill in the new user form
And I press "Sign up"
Then I should be on the getting started page
And I should see "Well, hello there!"
And I fill in the following:
| profile_first_name | O |

This example was obtained from Github https://github.com/diaspora/diaspora/tree/master/features/mobile, we were able to learn how  to write cucumber test by exploring this tests.

Working with cucumber tests in RapidFTR

  • To be able to begin testing in RapidFTR follow the link below  Running Tests in RapidFTR
  • Cucumber – Use these for testing User Flows – end to end scenarios that touch upon multiple functionality. Don’t use these for trivial tests, try using the Unit tests instead.
  • Cucumber Headless – These are tests that don’t involve any Javascript, so they can be run with simple HTTP GET/POST (curl-style) requests, and can be verified by inspecting the response.
  • Cucumber Browser – These tests run Javascript (such as dropdowns, dialogs, etc), and thus need a running browser environment, in our case Firefox.
  • API Tests – These test the public JSON API
  • Related gems: Cucumber, Capybara, json_spec
  • Related folders: features/ This folder is where the cucumber tests are located and created and where we are required to add the cucumber tests.

To run all the cucumber tests in Rapid FTR

# Run all cucumber tests
bundle exec rake cucumber:all

# Run headless tests
bundle exec rake cucumber:headless

# Run browser tests
bundle exec rake cucumber:browser

To be able to run a test for a specific feature in RapidFTR

The correct way is to run it using the cucumber executable if you’re using Rails 2, or bundle exec cucumber if you’re using Rails 3 (and thus Bundler).

To run a specific feature:

[command] features/signing_in.feature

To run a specific scenario from that feature:

[command] features/signing_in.feature:6

The line number can be any line inside that feature, but is usually the first line.

If you run rake cucumber:ok and some scenarios fail, at the bottom of the output you will see something like this:

cucumber features/sigining_in.feature:6 # Signing in via form

You can triple-click this line and paste it into your terminal to just run that scenario.

At the moment we are now working on the code for the cucumber test to be do our first cucumber test hurray!!!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s