Michael MacDonald

Test Business Behaviour, Don’t Rely on UI

In Testing on January 26, 2011 at 1:15 am

I often see Cucumber features written like this:

Given I a have an account with email: "user@test.com" and password: "password"
When I go to the log in page
And I fill in "Email" with "user@test.com"
And I fill in "Password" with "password"
And I press "Log in"
Then I should see "Logged in successfully."
And I should not see "Log in"

It works and does the job but I feel that it isn’t enough. It’s fragile in several ways.

Faster Cucumbering With Pagination

In Rails, Testing on November 25, 2010 at 5:30 pm

When writing a cucumber feature that involves pagination, the easiest thing to do is to create the required number of objects to generate pagination.

Given 31 tasks exist  # pagination defaults to 30

The downside of course is speed. Creating a large number of complex objects can add a lot of extra wait time to your cucumber runs. In my case, although I only had a few scenarios that involved pagination, my per_page setting was 50 and the objects I was creating were complex. The end result was a extra couple of (unnecessary) minutes. It wasn’t too bad so I left myself a TODO to fix it one day and that day finally came.

Javascript Testing with Cucumber, Capybara and env.js

In Rails, Testing on June 12, 2010 at 9:05 am

Tim Riley was excited when he discoved capybara and wrote an excellent blog post about Javascript Testing with Cucumber and Capybara. I was excited too but it took until I was sitting in a hallway at railsconf recharging my laptop before I found the time to clone Tim’s demo app and give capybara a try. I was impressed! I ran the tests and Firefox opened up in the background, ran the test and closed almost in a blink of the eye. Wow, that was fast. So much faster than how I’ve previously tested my javascript with selenium and webrat. And no complicated setup or configuration.

Follow

Get every new post delivered to your Inbox.