Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact
 
For 2021 - online Python 3 training - see ((here)).

Our plans were to retire in summer 2020 and see the world, but Coronavirus has lead us into a lot of lockdown programming in Python 3 and PHP 7.
We can now offer tailored online training - small groups, real tutors - works really well for groups of 4 to 14 delegates. Anywhere in the world; course language English.

Please ask about private 'maintenance' training for Python 2, Tcl, Perl, PHP, Lua, etc.
Scenario outlines - tables of values to test - in Gherkin / Cucumber

Rather that writing large numbers of scenarios in Gherkin, we can write Scenario Outlines and then supply Example rows of data to fill in to those outlines - a great way of specifying a series of similar behaviours - a list of "if I do aaa with the value x then I get the result y" statements where x and y will vary, but aaa will be the same thing many times over.

This follows on from the example described [here].

Here's an example of a feature file using a scenario outline:

 Feature: Checking we know station names and passenger counts
 
 Scenario Outline: 
 When we ask for the full name for "<tlc>"
 Then we are told it is "<fullname>"
 Then we are also told it had <journeys> passengers
 
 Examples:
   | tlc  |  fullname      |  journeys   |
   | SWI  |  Swindon       |  3350444    |
   | DMH  |  Dilton Marsh  |  20084      |
   | PLY  |  Plymouth      |  2445464    |
   | SPP  |  Shippea Hill  |  12         |


Here is the implementation of those features:

  When(/^we ask for the full name for "(.*?)"$/) do |arg1|
    @station = loadStationFactory[arg1]
  end
  
  Then(/^we are told it is "(.*?)"$/) do |arg1|
    expect(@station.getFullName).to eq(arg1)
  end
  
  Then(/^we are also told it had (\d+) passengers$/) do |arg1|
    expect(@station.getPassengers).to eq(arg1.to_i)
  end


And here are the results when we run all of those tabulated tests:

 munchkin:lr grahamellis$ cucumber -s cucTables
 Feature: Checking we know station names and passenger counts
 
   Scenario Outline: 
     When we ask for the full name for "<tlc>"
     Then we are told it is "<fullname>"
     Then we are also told it had <journeys> passengers
 
     Examples: 
       | tlc | fullname     | journeys |
       | SWI | Swindon      | 3350444  |
       | DMH | Dilton Marsh | 20084    |
       | PLY | Plymouth     | 2445464  |
       | SPP | Shippea Hill | 12       |
 
 4 scenarios (4 passed)
 12 steps (12 passed)
 0m0.259s
 munchkin:lr grahamellis$


Source:
Station feature file - [here]
Step implemenation - [here]
and the file we're testing - from another module
stations.py - [here]
(written 2015-10-23)

 
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articles
R221 - Ruby - Introduction to Cucumber
  [4380] Behaviour Driven Development / Ruby and Cucumber - (2015-01-02)
  [4381] Installing Cucumber (Ruby) - (2015-01-03)
  [4382] Second step Cucumber and Gherkin - beyond Hello World - (2015-01-03)
  [4383] Improved test in Cucumber with RSpec - (2015-01-03)
  [4384] Installing Cucumber on Ubuntu - cannot load such file -- mkmf (LoadError) message - (2015-01-04)
  [4386] Guide exercise to help you learn Gherkin, Cucumber and Rspec - (2015-01-06)
  [4551] Testing your new class - first steps with cucumber - (2015-10-23)


Back to
Testing your new class - first steps with cucumber
Previous and next
or
Horse's mouth home
Forward to
RUby - loading, using, changing, storing JSON format data
Some other Articles
Strings in C - strncmp strncpy and friends
Preprocessor directives in C and C++ - what they mean
Passing information into functions in C - by name, by value
RUby - loading, using, changing, storing JSON format data
Scenario outlines - tables of values to test - in Gherkin / Cucumber
Build up classes into applications sharing data types in Ruby
Clarrissa-Marybelle - too long to really fit?
Melksham - two small townships, or one big one?
RUH Hopper - experience and thoughts forward
4759 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96 at 50 posts per page


This is a page archived from The Horse's Mouth at http://www.wellho.net/horse/ - the diary and writings of Graham Ellis. Every attempt was made to provide current information at the time the page was written, but things do move forward in our business - new software releases, price changes, new techniques. Please check back via our main site for current courses, prices, versions, etc - any mention of a price in "The Horse's Mouth" cannot be taken as an offer to supply at that price.

Link to Ezine home page (for reading).
Link to Blogging home page (to add comments).

1 unpublished comment pending on this page

edit your own (not yet published) comments

© WELL HOUSE CONSULTANTS LTD., 2021: 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/mouth/4552_Sce ... umber.html • PAGE BUILT: Sun Oct 11 16:07:41 2020 • BUILD SYSTEM: JelliaJamb