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 breakpoint assert @exited_cleanly, "Process did not exit cleanly: #{@stdout}" end
Step 2 − We can also define a separate debug step like the following in the step definition file.
Then /^I debug$/ do breakpoint 0 end
Step 3 − Webrat 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.
save_and_open_page
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| save_and_open_page click_link(link) end