Rocket Fuelled Cucumbers discusses strategies for dealing with slow cucumber test suites, including:
- Using Spork to preload support code to speed up test runs
- Tagging tests to run focused subsets based on features, filenames, or tags
- Distributing tests across multiple servers using Testjour to parallelize testing
- Looking to cloud providers like EC2 to gain additional hardware resources
- Dividing applications and tests along service boundaries to isolate components
4. Scenario: Happy Railsconf attendees
Given you have a vague idea what Cucumber is
When Joseph completes his presentation
Then you should understand the scaling choices
And you should feel better prepared to face them
5. Cucumber
Feature: Filling Cucumbers with
• BDD framework rocket fuel
• Plaintext Scenario: Rocket fuel
Given I have trained monkeys
• Promotes When I click the launch button
communication Then the monkeys should not die
Given /^I have trained monkeys$/ do
@test_pilots << Monkeys.new
end
22. Development Feedback
Its too slow to run the cukes.
Just push the code and run away
23. Reuse - Spork
$ spork cucumber
$ cucumber --drb
require 'rubygems'
require 'spork'
Spork.prefork do
puts "I'm loading all the heavy stuff..."
end
Spork.each_run do
puts "I'm loading the stuff just for this run..."
# Cucumber hooks must go here
end
git://github.com/timcharper/spork.git
24. Slow services
• Search
Before('@solr') do
• Solr
Solr.boot unless Solr.running?
• Sphinx end
• Databases
• Mongo Feature: Searching
• Redis
@solr
• Mysql Scenario: Indexed search
• Message Queues Given ...
When ...
• RabbitMQ
Then ...
25. Run Just Enough Tests
Autotest
# * Test files must be stored in test/
# * Test files names must start with test_
# * Test class names must start with Test
# * Implementation files must be stored in lib/
# * Implementation files must match up with a
# test file named
# test_.*implementation.rb
Cucover
@analyzer = Rcov::CodeCoverageAnalyzer.new
29. Just enough Database
INSERT INTO `cities`
(`name`) VALUES ('Test name')
SELECT * FROM `cities` INSERT INTO
WHERE (`cities`.`id` = 105838) `venues` ...
SELECT * FROM
Cache city data
`venues`
WHERE ...
venue data Cache
78. Divide and Concuquer
Scenario: Related artists
Given an artist “SYGC”
And “M.Bison” is related to “SYGC”
When I visit the artist
Then I should see within Similar
Artists a link to “M.Bison”
79. Divide and conquer
Rails
Scenario: Related artists
Given an artist “SYGC”
And “M.Bison” is related to “SYGC”
When I visit the artist
Then I should see within Similar
Artists a link to “M.Bison”
80. Divide and conquer
Related
Rails Artists
Service
Scenario: Related artists
Given an artist “SYGC”
And “M.Bison” is related to “SYGC”
When I visit the artist
Then I should see within Similar
Artists a link to “M.Bison”
81. Divide and conquer
related(artist)
Related
Rails Artists
Service
Scenario: Related artists
Given an artist “SYGC”
And “M.Bison” is related to “SYGC”
When I visit the artist
Then I should see within Similar
Artists a link to “M.Bison”
82. Divide and conquer
related(artist)
Related
Rails HTML Artists
Service
Scenario: Related artists
Given an artist “SYGC”
And “M.Bison” is related to “SYGC”
When I visit the artist
Then I should see within Similar
Artists a link to “M.Bison”
83. Divide and conquer
related(artist)
Related
Rails HTML Artists
Service
Scenario: Related artists
Given an artist “SYGC”
And “M.Bison” is related to “SYGC”
When I visit the artist
Then I should see within Similar
Artists a link to “M.Bison”
84. Divide and conquer
related(artist)
Related
Rails HTML Artists
Service
unit test unit test
Scenario: Related artists
Given an artist “SYGC”
And “M.Bison” is related to “SYGC”
When I visit the artist
Then I should see within Similar
Artists a link to “M.Bison”
85. Don’t use Acceptance
tests
http://jamesshore.com/Blog/Alternatives-
to-Acceptance-Testing.html
Heresy!
86. Pairwise
Scenario: Testing Cucumber against different environments
Given I have a rails app <Rails version>
And I’m using Ruby <Ruby version>
And I am using the <Test Framework>
And I am using the driver <Driver>
Then Cucumber should install and play nicely
Examples:
| Rails version | Ruby version | test framework | Driver |
| 3.0 | 1.8.7 | Rspec | Webrat |
| 3.0 | 1.8.7 | Testunit | Capybara |
| 3.0 | 1.8.7 | Rspec | Capybara |
| 3.0 | 1.8.7 | Testunit | Webrat |
| 3.0 | 1.9 | Rspec | Webrat |
| 3.0 | 1.9 | Testunit | Webrat |
| 2.3.1 | 1.9 | Rspec | Webrat |
....