Table of Contents....5
About the Author....11
About the Technical Reviewer....12
Introduction....13
Chapter 1: Introduction to Jasmine....15
Learning Goals....18
Introduction....18
Download....19
A New JavaScript Project....19
Setting Up Jasmine....21
Write Your First Dummy Spec....24
describe....26
it....26
expect....26
Start Your Application Implementation: Test-Driven Development (TDD)....27
More Specs....35
Refactoring....44
TDD Flow....45
Jasmine Matchers....46
Setup and Teardown....47
Nesting describe Blocks....50
Disabling Suites and Pending Specs....54
Tasks and Quizzes....55
Key Takeaways....57
Chapter 2: Advanced Jasmine....58
Learning Goals....59
Stubbing and Mocking....59
Stubbing with Jasmine....60
Mocking with Jasmine....66
Stubbing and Mocking As Testing Tools....74
Task Details....74
Key Takeaways....75
Chapter 3: Using Minitest....76
Learning Goals....76
Introduction....77
First Unit Test....77
TDD: Test-Driven Development....78
Verify That You Can Run the Test Suite....78
Test Real Requirements....81
Red Light....82
Make the Test Better....86
Make Them Green....92
assert_nil....97
Refactor....97
Running a Single Test....99
seed....99
Multiple Files....100
Using rake....105
Require All Files of Your Project....106
RubyMine Integration....109
Minitest: Other Assert Commands....117
Task Details....118
Key Takeaways....120
Chapter 4: Introduction to RSpec....122
Learning Goals....122
Introduction....124
New Project....124
rspec Version....126
Initialize RSpec....127
RSpec Configuration....127
Inside the spec Folder....131
Describing....131
Sanity Check....133
Documentation Formatter....136
Let’s Write a Real Specification....137
Run and Watch That Fail and Then Fix It....140
Sharing Setup Code....147
before Hook....150
Helper Methods....152
Share with let....154
Context....154
Running Specific Examples....157
RubyMine Integration....164
Task Details....169
Key Takeaways....170
Chapter 5: Useful RSpec Tools....171
Learning Goals....171
Hooks....172
before(:suite)....172
before(:all)....179
before(:example) or Simply before....185
after Hooks....185
Multiple Hooks....185
subject....185
Extending RSpec with Helper Methods in Modules....193
Metadata....198
described_class....199
Custom Metadata....200
Filtering....204
Tasks and Quizzes....205
Quiz....205
Task Details....205
Key Takeaways....210
Chapter 6: Introduction to Cucumber....211
Learning Goals....211
Introduction....212
The Project and Cucumber Installation....212
cucumber Executable....214
Let’s Initialize....215
Let’s Invoke cucumber....217
Write Your First Scenario....218
Defining Steps (with Pending Implementation)....221
Implement the First Step....223
Implement the Second Step....226
Implement the Third Step....229
Implementing the Feature in Application Code....230
Introduce One More Scenario....231
Proper Implementation to Support Any Addition....235
Removing Duplication with Scenario Outlines....236
RSpec Integration....238
Add rspec in Gemfile....239
Use RSpec Matchers....240
Task Details....240
Key Takeaways....241
Chapter 7: Advanced Cucumber....243
Learning Goals....243
Introduction....244
Gherkin Keywords....244
Feature....245
Background....246
Scenario....247
And, But, and *....249
Scenario Names and Description....249
Scenario State....250
Data Tables....250
Spoken Languages....254
Which Languages?....254
Specify the Language of a Feature File....255
Localization of Gherkin Keywords....255
A More Extensive Example....256
Initialize the Project....256
Gemfile....256
Initialize Cucumber....257
The Feature File....257
Undefined Steps....258
Implementing the First Step....260
Implementing the Second Step....263
Implementing the Third Step....265
Implementing the Fourth Step....271
Scenario Outline....275
Some Rooms Are Not Available....278
Increase Your Confidence with Some Extra Examples....287
RSpec and Unit Tests....289
Rest of the Feature....293
Cucumber Command Line....293
Dry Run....293
Invoking a Single Feature....296
Invoking a Single Scenario....297
Tags....303
Hooks....310
Doc Strings....319
Cucumber and RubyMine Integration....320
Task Details....321
Key Takeaways....321
Index....323
Learn the principles behind test-driven development (TDD) and behavior-driven development (BDD) and see how Jasmine, RSpec and Cucumber can be used to your advantage. This book examines some of the leading technologies used for testing.
You'll see how to use Jasmine’s features to work with a JavaScript application. You will learn how to use Mini Test and RSpec with Ruby and Rubymine. Finally, you’ll use Cucumber to develop your software using a BDD approach.
Understanding test automation is a vital skill for any web developer. Practical Test Automation breaks down for you some of the important TDD and BDD technologies on the modern web.
This book is for anyone who wants to learn test automation and more about test-driven development and behavior-driven development.