Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact
 
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
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!



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.



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
  step_definitions
  
  hello/step_definitions:
  hello_steps.rb Ruby code to implement tests - 2nd file


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

R221 - Ruby - Introduction to Cucumber
  [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)
  [4552] Scenario outlines - tables of values to test - in Gherkin / Cucumber - (2015-10-23)


Back to
Well House Consultants / Well House Manor - Prices for 2015
Previous and next
or
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., 2024: 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/4380_Beh ... umber.html • PAGE BUILT: Sun Oct 11 16:07:41 2020 • BUILD SYSTEM: JelliaJamb