The Cucumber Book. Extracted from: Behaviour-Driven Development for Testers and Developers. The Pragmatic Bookshelf



Similar documents
Agile Web Development with Rails 4

icloud for Developers

Practical Programming, 2nd Edition

Web Development Recipes

Do Less, Accomplish More with Lean Thinking

Rapid Android Development

Copyright 2010 The Pragmatic Programmers, LLC.

Copyright 2008 The Pragmatic Programmers, LLC.

Enterprise Recipes with Ruby and Rails

Cucumber: Finishing the Example. CSCI 5828: Foundations of Software Engineering Lecture 23 04/09/2012

Programming Cocoa with Ruby Create Compelling Mac Apps Using RubyCocoa

Pragmatic Version Control

FEC Secure IPSec Client

Test-Drive ASP.NET MVC

Most of the security testers I know do not have

CA Workload Automation Agent for Microsoft SQL Server

Chapter 1 Manage Users, Computers and Groups...2. Chapter 2 Managing and Maintaining Access to Resources...43

Rails Cookbook. Rob Orsini. O'REILLY 8 Beijing Cambridge Farnham Koln Paris Sebastopol Taipei Tokyo

Failover Manager for WhatsUp Gold v16.0 Quick Start Guide

Pragmatic Version Control

Web Service. User Manual

SQL Server 2005 Reporting Services (SSRS)

StarPort iscsi and ATA-over-Ethernet Initiator: Using Mirror (RAID1) disk device

7.94 New Features Guide

AvePoint CRM Migration Manager for Microsoft Dynamics CRM. Release Notes

Testadon Certification

HP Operations Orchestration Software

ASP.NET MVC. in Action JEFFREY PALERMO JIMMY BOGARD BEN SCHEIRMAN MANNING. (74 w. long.) WITH MVCCONTRIB, N HIBERNATE, AND MORE.

Scenario 2: Cognos SQL and Native SQL.

Application Development Setup Guide

Key Benefits of Microsoft Visual Studio 2008

Data Domain Profiling and Data Masking for Hadoop

IMPLEMENTATION GUIDE. API Service. More Power to You. May For more information, please contact

Transform. Training Courses A Bottomline Guide

Simulated Health Records Simplified

Guide to Operating SAS IT Resource Management 3.5 without a Middle Tier

Using the Motorola Data Collection Solution with MSP

Sophos Anti-Virus for Mac OS X Help. For networked and single computers running Mac OS X version 10.4 or later

UNIX Operating Environment

Pipeliner CRM Phaenomena Guide Opportunity Management Pipelinersales Inc.

Auditing UML Models. This booklet explains the Auditing feature of Enterprise Architect. Copyright Sparx Systems Pty Ltd

Helm 4 Windows Event Viewer

Adobe Acrobat 9 Deployment on Microsoft Windows Group Policy and the Active Directory service

Programmabilty. Programmability in Microsoft Dynamics AX Microsoft Dynamics AX White Paper

The Starter League Course Catalog

Source Control Guide: Git

Troubleshooting File and Printer Sharing in Microsoft Windows XP

Monitoring Nginx Server

Getting started with API testing

Cucumber and Capybara

Scheduling in SAS 9.4 Second Edition

The IBM i on Rails + + Anthony Avison anthony@powerruby.com. Copyright 2014 PowerRuby, Inc.

This course provides students with the knowledge and skills to develop ASP.NET MVC 4 web applications.

FEATURE COMPARISON BETWEEN WINDOWS SERVER UPDATE SERVICES AND SHAVLIK HFNETCHKPRO

Scribe Demonstration Script Web Leads to Dynamics CRM. October 4,

HotSpot Enterprise Mobile Printing Solution. Security Whitepaper

Web Development using PHP (WD_PHP) Duration 1.5 months

Usage Analysis Tools in SharePoint Products and Technologies

Sample- for evaluation only. Advanced Excel. TeachUcomp, Inc. A Presentation of TeachUcomp Incorporated. Copyright TeachUcomp, Inc.

Design Document Version 0.0

Blackbaud StudentInformationSystem. Reports Guide for Admissions Office

StarterPak: HubSpot and Dynamics CRM Lead and Contact Synchronization

Oracle Agile Engineering Data Management

Flow Publisher v1.0 Getting Started Guide. Get started with WhatsUp Flow Publisher.

Load testing with. WAPT Cloud. Quick Start Guide

ALTIRIS Notification Connector Configuration Guide

RTX Runtime with Service Pack 2 WES7 DEPLOYMENT GUIDE

User Document. Adobe Acrobat 7.0 for Microsoft Windows Group Policy Objects and Active Directory

StreamServe Persuasion SP5 Ad Hoc Correspondence and Correspondence Reviewer

7 ADULT COLORING PAGES

SOA and Virtualization Technologies (ENCS 691K Chapter 2)

New Features for Sybase Mobile SDK and Runtime. Sybase Unwired Platform 2.1 ESD #2

StarWind Virtual SAN Hyper-Converged Platform Quick Start Guide

Accounts Payable Workflow Guide. Version 11.2

Project management integrated into Outlook

CA Workload Automation Agent for Remote Execution

Introduction to AutoMate 6

Sample- for evaluation purposes only! Advanced Outlook. TeachUcomp, Inc. A Presentation of TeachUcomp Incorporated. Copyright TeachUcomp, Inc.

Automation and Connectivity: The Role of Microsoft Business Solutions Navision Application Server

Educational Collaborative Develops Big Data Solution with MongoDB

StreamServe Persuasion SP4 Service Broker

Introduction to Zetadocs for NAV

Deploying Adobe Acrobat Using Microsoft Windows Terminal Service ADOBE SYSTEMS INCORPORATED

The Learn-Verified Full Stack Web Development Program

Module 1: Introduction to Active Directory Infrastructure

Transcription:

Extracted from: The Cucumber Book Behaviour-Driven Development for Testers and Developers This PDF file contains pages extracted from The Cucumber Book, published by the Pragmatic Bookshelf. For more information or to purchase a paperback or PDF copy, please visit http://www.pragprog.com. Note: This extract contains some colored text (particularly in code listing). This is available only in online versions of the books. The printed versions are black and white. Pagination might vary between the online and printer versions; the content is otherwise identical. Copyright 2010 The Pragmatic Programmers, LLC. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form, or by any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior consent of the publisher. The Pragmatic Bookshelf Dallas, Texas Raleigh, North Carolina

Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and The Pragmatic Programmers, LLC was aware of a trademark claim, the designations have been printed in initial capital letters or in all capitals. The Pragmatic Starter Kit, The Pragmatic Programmer, Pragmatic Programming, Pragmatic Bookshelf, PragProg and the linking g device are trademarks of The Pragmatic Programmers, LLC. Every precaution was taken in the preparation of this book. However, the publisher assumes no responsibility for errors or omissions, or for damages that may result from the use of information (including program listings) contained herein. Our Pragmatic courses, workshops, and other products can help you and your team create better software and have more fun. For more information, as well as the latest Pragmatic titles, please visit us at http://pragprog.com. The team that produced this book includes: Jackie Carter (editor) Potomac Indexing, LLC (indexer) Kim Wimpsett (copyeditor) David J Kelly (typesetter) Janet Furlow (producer) Juliet Benda (rights) Ellie Callahan (support) Copyright 2012 Pragmatic Programmers, LLC. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form, or by any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior consent of the publisher. Printed in the United States of America. ISBN-13: 978-1-934356-80-7 Printed on acid-free paper. Book version: P2.0 August 2012

Contents Foreword..............? Acknowledgments...........? Preface..............? Part I Cucumber Fundamentals 1. Why Cucumber?............? 1.1 Automated Acceptance Tests? 1.2 Behaviour-Driven Development? 1.3 Living Documentation? 1.4 How Cucumber Works? 1.5 What We Just Learned? 2. First Taste.............? 2.1 Understanding Our Goal? 2.2 Creating a Feature? 2.3 Creating Step Definitions? 2.4 Implementing Our First Step Definition? 2.5 Running Our Program? 2.6 Changing Formatters? 2.7 Adding an Assertion? 2.8 Making It Pass? 2.9 What We Just Learned? 3. Gherkin Basics............? 3.1 What s Gherkin For?? 3.2 Format and Syntax? 3.3 Feature? 3.4 Scenario? 3.5 Comments?

Contents v 3.6 Spoken Languages? 3.7 What We Just Learned? 4. Step Definitions: From the Outside.......? 4.1 Steps and Step Definitions? 4.2 Capturing Arguments? 4.3 Multiple Captures? 4.4 Flexibility? 4.5 Returning Results? 4.6 What We Just Learned? 5. Expressive Scenarios...........? 5.1 Background? 5.2 Data Tables? 5.3 Scenario Outline? 5.4 Nesting Steps? 5.5 Doc Strings? 5.6 Staying Organized with Tags and Subfolders? 5.7 What We Just Learned? 6. When Cucumbers Go Bad..........? 6.1 Feeling the Pain? 6.2 Working Together? 6.3 Caring for Your Tests? 6.4 Stop the Line and Defect Prevention? 6.5 What We Just Learned? Part II A Worked Example 7. Step Definitions: On the Inside........? 7.1 Sketching Out the Domain Model? 7.2 Removing Duplication with Transforms? 7.3 Adding Custom Helper Methods to the World? 7.4 Organizing the Code? 7.5 What We Just Learned? 8. Support Code.............? 8.1 Fixing the Bug? 8.2 Bootstrapping the User Interface? 8.3 Making the Switch? 8.4 Using Hooks?

Contents vi 8.5 Building the User Interface? 8.6 What We Just Learned? 9. Dealing with Message Queues and Asynchronous Components...........? 9.1 Our New Asynchronous Architecture? 9.2 How to Synchronize? 9.3 Implementing the New Architecture? 9.4 Fixing the Flickering Scenario? 9.5 What We Just Learned? 10. Databases.............? 10.1 Introducing ActiveRecord? 10.2 Refactoring to Use a Database? 10.3 Reading and Writing to the Database? 10.4 Cleaning the Database with Transactions? 10.5 Cleaning the Database with Truncation? 10.6 What We Just Learned? Part III Cucumber Applied 11. The Cucumber Command-Line Interface......? 11.1 Cucumber s Command-Line Options? 11.2 Running a Subset of Scenarios? 11.3 Changing Cucumber s Output? 11.4 Specifying the Location of Step Definitions? 11.5 Managing Your Work in Progress (WIP)? 11.6 Using Profiles? 11.7 Running Cucumber from Rake? 11.8 Running Cucumber in Continuous Integration? 11.9 What We Just Learned? 12. Testing a REST Web Service.........? 12.1 In-Process Testing of Rack-Based REST APIs? 12.2 Out-of-Process Testing of Any REST API? 12.3 What We Just Learned? 13. Adding Tests to a Legacy Application.......? 13.1 Characterization Tests? 13.2 Squashing Bugs? 13.3 Adding New Behavior?

vii Contents 13.4 Code Coverage? 13.5 What We Just Learned? 14. Bootstrapping Rails...........? 14.1 Running the Generators? 14.2 Creating a User? 14.3 Posting a Message? 14.4 Associating a Message with a User? 14.5 Creating a Controller by Hand? 14.6 Implementing the View? 14.7 What We Just Learned? 14.8 Try this? 15. Using Capybara to Test Ajax Web Applications....? 15.1 Implementing a Simple Search Without Ajax? 15.2 Searching with Ajax? 15.3 The Capybara API? 15.4 Taking Screenshots? 15.5 What We Just Learned? 16. Testing Command-Line Applications with Aruba....? 16.1 Simple Interfaces? 16.2 Our First Aruba Feature? 16.3 Working with Files and Executables? 16.4 Interacting with User Input? 16.5 Using Aruba s Ruby DSL? 16.6 What We Just Learned? A1. Using Cucumber with Other Platforms......? A2. Installing Cucumber...........? A2.1 Installing Ruby? A2.2 HTTP Proxy Settings? A2.3 Installing Bundler? A2.4 Installing Cucumber (and RSpec)? A2.5 Installing Other Gems? A2.6 Choosing a Text Editor? A3. Ruby Gem Versions...........? A4. Bibliography.............? Index...............?