Cucumber Recipes Automate Anything with BDD Tools and Techniques by Ian Dees, Matt Wynne, Aslak Hellesøy Version: P1.0 (February 2013) Copyright © 2013 The Pragmatic Programmers, LLC. This book is licensed to the individual who purchased it. We don't copy-protect it because that would limit your ability to use it for your own purposes. Please don't break this trust—you can use this across all of your devices but please do not share this copy with other members of your team, with friends, or via file sharing services. Thanks. —Dave & Andy. 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 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. Table of Contents Foreword Agile Patterns Platforms Progress Acknowledgments Introduction Who This Book Is For How to Use This Book Getting the Tools You’ll Need Online Resources 1. Cucumber Techniques Recipe 1. Compare and Transform Tables of Data Recipe 2. Generate an RTF Report with a Custom Formatter Recipe 3. Run Slow Setup/Teardown Code with Global Hooks Recipe 4. Refactor to Extract Your Own Application Driver DSL Recipe 5. Define Steps as Regular Ruby Methods Recipe 6. Compare Images Recipe 7. Test Across Multiple Cores Recipe 8. Test Across Multiple Machines with SSH Recipe 9. Run Your Features Automatically with Guard and Growl Recipe 10. Add Cucumber to Your Continuous Integration Server Recipe 11. Publish Your Documentation on Relish Recipe 12. Test Through Multiple Interfaces Using Worlds Recipe 13. Manipulate Time Recipe 14. Drive Cucumber’s Wire Protocol Recipe 15. Implement a Wire Protocol Listener 2. Java Recipe 16. Use Cucumber Directly with JRuby Recipe 17. Use Cucumber with Java via Cucumber-JVM Recipe 18. Drive a Spring + Hibernate Project Recipe 19. Test a Grails App Using grails-cucumber Recipe 20. Test Scala Code Recipe 21. Test Clojure Code Recipe 22. Drive a Swing Interface with FEST 3. .NET and Windows Recipe 23. Get Good Text Output on Windows Recipe 24. Test .NET Code with SpecFlow Recipe 25. Drive a Windows App Using White Recipe 26. Test Windows GUIs with AutoIt Recipe 27. Test on Windows Phone 4. Mobile and Web Recipe 28. Test on iOS Using Frank Recipe 29. Test Android Apps with Calabash Recipe 30. Parse HTML Tables Recipe 31. Drive JavaScript/CoffeeScript Using Cucumber-JS Recipe 32. Test a Web App Using Watir Recipe 33. Test a PHP App with cuke4php Recipe 34. Play Back Canned Network Data Using VCR Recipe 35. Drive a Flash App Using Cuke4AS3 Recipe 36. Monitor a Web Service Using Nagios and Cucumber 5. Other Languages and Platforms Recipe 37. Drive a Mac GUI Using AppleScript and System Events Recipe 38. Drive a Mac GUI Using MacRuby and AXElements Recipe 39. Test Python Code Using Lettuce Recipe 40. Test Erlang Code Recipe 41. Test Lua Code Using cucumber-lua Recipe 42. Test a GUI on Linux, Mac, or Windows with Sikuli Recipe 43. Test an Arduino Project Using Serial A1. RSpec Expectations A1.1 Basics A1.2 Custom Matchers A1.3 Alternatives Bibliography Copyright © 2013, The Pragmatic Bookshelf. Early Praise for Cucumber Recipes With Cucumber Recipes you feel like the authors are right there with you, offering you advice, showing you hidden gems, or gently chastising you for things you know you shouldn’t be doing. From general advice about taming unruly test suites or scaling out across multiple servers, to craziness like testing embedded Arduino hardware projects, they manage to cover an enormous amount of ground in a small space. Prepare for a fun and informative ride. → Dan North Originator of BDD and author of the RSpec story runner (Cucumber’s predecessor) There are many cookbooks but very few “chef books.” Cucumber Recipes is inspiring enough to qualify as a chef book. If there’s a will and a desire to use Cucumber in the process, Cucumber Recipes will more than likely show you a way...or many ways! From the basic to the esoteric, there’s something for everyone in Cucumber Recipes. →Michael Larsen Senior quality assurance engineer, SocialText It is good to see that a free tool like Cucumber has been able to build up a community that treats BDD as its own child and carries it to nearly every possible platform and technology. This book provides a closer look at the details. →Gáspár Nagy Developer coach at TechTalk, creator of SpecFlow If you’re automating tests of any kind using Cucumber, in any language, against any type of software, you need this cookbook. Its recipes will help you write useful, easily maintained tests for even the most puzzling scenarios. Like all good cookbooks, it teaches good techniques and principles that will help you improve all your tests. Best of all, you can actually code the examples yourself, and learn by doing. → Lisa Crispin Co-author, Agile Testing: A Practical Guide for Testers and Agile Teams Cucumber Recipes has testing solutions for a variety of platforms. It is a powerful book that gives us useful tips to use BDD in our chosen environment. To realize the power of BDD, Cucumber Recipes is a must on every software test engineer’s table. →Kavitha Naveen Senior lead—quality engineering Foreword There was a time when one could analyze all that a program needed to do and then write the program that met that need. This stopped being a winning strategy when computers got big enough and fast enough to hold a description of the problem, not just the solution. I embraced this change that went by the name of object-oriented programming. The advice was to divide large programs into parts that captured natural diversity. Then we were to program the parts to ask other parts for results without saying exactly how these results were to be achieved. This sounded simple. We no longer had to think everything through all of the time. Then, when we discovered one more case late in development, we were thankful we kept that complexity at a distance. It was a good plan, but it turned out to be not quite that simple. Not only was there more than one way to chop up a program into parts, there was no easy way to tell which approach was going to prove to be leveraged when unforeseen needs surfaced, as they always do. Agile We forged ahead. We found dozens of techniques that helped keep track of what we had done, where we were going, and, especially, how to say “yes, we can” when asked to do something never once mentioned until our programs were used. When we say Agile today, we’re distinguishing ourselves from the days when we would resist change even if it meant finishing a program that wouldn’t be used. We asked our pioneers to experiment. We asked that they try new things and share with each other how they worked out. We asked our best developers to think about these new problems: where have we been, where are we going, and how will we know when we get there? This book carries that tradition forward. Let me explain how.
Description: