Ted Wise header image 2

Make those lazy BA’s write the test scripts 

Copy ShortURL

June 12th, 2009 · View Comments · Consulting

Ok, I'm kidding about the lazy part.

But here's an interesting open source tool - Cucumber. It's a Behavior Driven Development (BDD) testing framework.

You write the test scripts in plain language:

Feature: Search courses
In order to ensure better utilization of courses
Potential students should be able to search for courses
Scenario: Search by topic
Given there are 240 courses which do not have the topic "biology"
And there are 3 courses A,B,C that each have "biology" as one of the topics
When I search for "biology"
Then I should see the following courses:
| title |
| A |
| B |
| C |

And then interpret them using test code:

Given /there are (.*) courses which do not have the topic "(.*)"/ do |num_courses, topic_name|
 ... write the code to get the number of courses without the topic and verify the number...
end
 
Given /there are (.*) courses (.*) that each have "(.*)" as one of the topics/ do |num_courses, course_names, topic_name|
 ... write the code to check this one too...
end
 
When /I search for "(.*)"/ do |topic_name|
 ... search for the topic name and save the list of courses ...
end
 
Then /I should see the following courses/ do |table|
 ... check that the saved list of courses matches the data in the table...
end

The idea is to let the tests describe the behavior of the system and then code to fulfill the tests. Cucumber is written in Ruby and so are the tests. But it runs on JRuby and on IronRuby so it can be used to test Java code and .Net code.

Share and Enjoy:
  • email
  • Twitter
  • Facebook
  • Slashdot
  • LinkedIn
  • Digg
  • DZone
  • Reddit
blog comments powered by Disqus