14 Apr
Posted by Elf Sternberg as programming, ruby, web development
So, remember my comment about unit testing yesterday? This is what it looks like today. Here’s the features page:
Feature: Login
In order to use the system
As a customer
I want to log in
Scenario: Access page
Given I am at the login page
Then the page title should be "SecretProject"
Scenario: Log in
When I log in as "username" password "redacted"
Then the page title should be "SecretProject - Project List"
And here’s the steps:
Given 'I am at the login page' do @browser.goto @options[:address] end Then /the page title should be "(.*)"/ do |title| @browser.title.should == title end When /^I log in as "([^"]*)" password "([^"]*)"$/ do |arg1, arg2| @browser.text_field(:name, 'username').set(arg1) @browser.text_field(:name, 'password').set(arg2) @browser.button(:xpath, "//input[@value='Login']").click end
While I’m not entirely sold on the COBOL-esque nature of the unit tests, I respect the way cucumber makes you think about what you’re doing and generate scenarios and codify the steps to fulfilling those scenarios, all the while working well within the context of things like WATIR, Matchy, and so forth.
RSS feed for comments on this post · TrackBack URI
Leave a reply