Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact
Python and Tcl - public course schedule [here]
Private courses on your site - see [here]
Please ask about maintenance training for Perl, PHP, Lua, etc
Behaviour Driven Development / Ruby and Cucumber

Articles in this "Introduction to Cucumber" series:
[link] - Installing Cucumber for Ruby
[link] - Hello Test Cucumber World
[link] - First real tests / second example
[link] - Improved tests with RSpec

You write code to meet a requirement. The requirement is that it behaves in a certain way. So when you call up your code in a certain way, you get a certain response.

Behaviour Driven Developement is where you start off by describing how you want to call your code ("access certain features") and the responses that you want to get. Only when you have written those scenarios do you actually go ahead and write the code so that it meets the required behaviour.

This is a very logical way of working - after all "the customer is king" and the customer for your code is the user of that code.

Cucumber is a Ruby gem which provides users with the ability to specify what their code will be required to do (using an English like language such as Gherkin). It then gives them the ability to wrie the actual tests that are going to be done to check that the code will run as specified. And if you run your cucumber on your application at this point, you'll get a whole load of red messages telling you that your code doesn't work yet!

Behaviour Driven Development

You then go ahead and implement, (write) the actual code that's needed to implement the specification, and keep running cucumber until ir works and goes all green.

Cucumber - behaviour driven development

As you enhance and develop your application, you'll add behaviours, then tests, then code to implement the behaviour that's required, and by rerunning cucumber you'll keep re-testing the previously implemented behavious so that you're assured than new features and behaviours haven't broken the previous ones.

The complete file set for this "Hello Cucumber World" example is:
  WomanWithCat:cuc grahamellis$ ls -R1 hello
  greet.rb Code to implement behaviour - 3rd and final file
  hello.feature Gherkin definition of feature - 1st file
  hello_steps.rb Ruby code to implement tests - 2nd file

1. Gherkin to describe - [here]
2. Ruby test specification - [here]
3. Implementation code - [here]

Behaviour and test driven developement becomes ever more important in our training courses, and in each of the public programming courses we teach we'll touch on the subject at the very least. Should it be appropriate for any of the delegate group we have we'll go deeper, as we will on private courses if so requested. Our public course schedule is [here], and most other weeks are avaibable for tailored private courses. At the time of writing (2nd January 2015), we have a busy private training schedule and apart from a few odd days, the next private course availability is for March.
(written 2015-01-02, updated 2015-01-03)

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

Q456 - Object Orientation and General technical topics - Test Driven Development and Behaviour Driven Development
  [4652] Testing new algorithms in PHP - (2016-02-20)
  [4634] Regression testing - via a very short C testing framework - (2016-01-29)
  [4542] The principle of mocking - and the Python Mock package - (2015-10-17)
  [4457] Test framework for TCL - Tcltest - some examples - (2015-03-11)
  [4387] Regression Testing my website - Cucumber and Watir - (2015-01-07)
  [4374] Test driven development, and class design, from first principles (using C++) - (2014-12-30)
  [4346] A behaviour driven example of writing a Java program - (2014-12-09)
  [4336] Test Driven Development - a first example of principle in C - (2014-12-01)
  [4326] Learning to program - comments, documentation and test code - (2014-11-22)

Back to
Well House Consultants / Well House Manor - Prices for 2015
Previous and next
Horse's mouth home
Forward to
Installing Cucumber (Ruby)
Some other Articles
Behaviour Driven Development / Ruby and Cucumber
Well House Consultants / Well House Manor - Prices for 2015
What FGW passengers want to talk about / and PHP programming to find out
Designing a base class and subclasses, and their extension, in C++
Well House Consultants, Well House Manor, First Great Western Coffee shop, TransWilts / 2014 web site reports
Final examples for 2014 - and a look at our 2015 training course options
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).

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2019: 404 The Spa • Melksham, Wiltshire • United Kingdom • SN12 6QL
PH: 01225 708225 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/mouth/4380_Beh ... umber.html • PAGE BUILT: Sat May 27 16:49:10 2017 • BUILD SYSTEM: WomanWithCat