Cucumber - Debugging

It is very likely that your test may fail due to unknown reasons. Identifying the cause of failure and correcting it is very important. This process is known as debugging. Following are a few tips and tricks, which makes Cucumber debugging a bit easy.

Debugging option is available with Eclipse. Place the break point. Click the file and debug using the following steps −

Step 1 − Place the manual break points in the Ruby step definition file.


require 'ruby-debug' 
Then /^the process should exit cleanly$/ do 
assert @exited_cleanly, "Process did not exit cleanly: #{@stdout}" 

Step 2 − We can also define a separate debug step like the following in the step definition file.

Then /^I debug$/ do 

Step 3Webrat is the default tool for cucumber testing with Rails. It lets you do things like click links, type and submit forms, and so on.

There will be times where you try to click on something, for example, and it’s not there. You’ll get a big blob of HTML thrown back, and figuring out what that exactly means can be a real drag.


Webrat provides a method save_and_open_page which captures the current HTML, saves it, and then will open it in a browser for you. Extremely useful.

When /^I follow "(.*)"$/ do |link| 
Kickstart Your Career

Get certified by completing the course

Get Started