The Cucumber Book: Behaviour-Driven Development for Testers and Developers (Pragmatic Programmers)
Format: PDF / Kindle (mobi) / ePub
Your customers want rock-solid, bug-free software that does exactly what they expect it to do. Yet they can't always articulate their ideas clearly enough for you to turn them into code. The Cucumber Book dives straight into the core of the problem: communication between people. Cucumber saves the day; it's a testing, communication, and requirements tool - all rolled into one.
We'll show you how to express your customers' wild ideas as a set of clear, executable specifications that everyone on the team can read. You'll learn how to feed those examples into Cucumber and let it guide your development. You'll build just the right code to keep your customers happy, and not a line more.
The first part of the book teaches you how to use the core features of Cucumber. You'll learn how to use Cucumber's Gherkin DSL to describe-- in plain language - the behavior your customers want from the system. You'll learn how to write Ruby code that interprets those plain language specifications and checks them against your application. In Part 2, you'll consolidate the knowledge you just gained with a worked example.
Although it was born in the Ruby community, you can use Cucumber to test almost any system, from a simple shell script or a Perl script, to enterprise PHP or a Java web application. In Part 3, you'll find a selection of recipes for some of the most common situations you'll encounter using Cucumber in the wild. You'll learn how to test Ajax-heavy web applications with Capybara and Selenium, REST web services, Ruby on Rails applications, command-line applications, legacy applications and lots more!
Written by the creator of Cucumber and one of its most experienced users and contributors, The Cucumber Book is an authoritative guide that will give you and your team all the knowledge you need to start using Cucumber with confidence.
What You Need:
Windows, Mac OS X (with XCode) or Linux
Ruby 1.9.2 and upwards
translated to their underlying method calls: command_line_applications/12/features/step_definitions/calculator_steps.rb Given /^the input "([^"]*)"$/ do |input| write_file 'input.txt', input end When /^the calculator is run$/ do run 'calculator input.txt' end When /^the calculator is run with no input$/ do run_interactive 'calculator' end When /^I enter the calculation "([^"]*)"$/ do |calculation| type calculation end Then /^the output should be
brilliant job explaining how you get started with Cucumber with plenty of easy-to-follow examples. → Rachel Davies Author, Agile Coaching To those of you wondering how to use Cucumber effectively, The Cucumber Book is the answer. Not content to write just a testing book, Aslak and Matt have packed it with practical insights on many aspects of software development. Studying this book will make you a better software developer. → Pat Maddox, B.D.D.M.F. RSpec Core team This is a
plain string: Given "I have 100 in my Account" do end We couldn’t write $100 here, because the $ has a special meaning when you define step definitions with strings. Any $ signs—including any letter or number following it—will be interpreted as an argument, which you will learn more about in Section 4.2, Capturing Arguments. This step definition uses an argument: Given "I have $amount in my Account" do |amount| end This step definition would match both of the following Gherkin
system to be testable. Michael Feathers’ Working Effectively with Legacy Code [Fea04] gives many practical examples of breaking up large systems that weren’t designed to be tested. Hold regular sessions with your team to talk about your architecture: what you like, what you don’t like, and where you’d like to take it. It’s easy to get carried away with ambitious ideas that evaporate into thin air soon after you get back to your desks, so make sure you try to leave these sessions with realistic,
clear that credit and debit are the right names for the methods on Account. In fact, deposit is something you’d more likely ask a Teller to do for you. These conversations happen all the time as you start to establish a ubiquitous language, and you’ll find they become easier and easier as your knowledge of the domain, and the ubiquitous language you all use to discuss it, grows. We’re going to rename the Account#deposit method to Account#credit. Since our test is nice and fast, we can just