It's been a while since my last post. I was actually working on a project where I had to do manual testing. The cost of automating functional tests for the project did not provide any real advantage considering the tight schedule. It did allow me to revisit a method in cucumber that I never thought I would ever use.
The ask method will pause the cucumber runtime and prompt the user for an input. So, if I had the following step: Given I am on the Nouvola Homepage The ask method could be added to the step definition like this: Given(/^I am on the Nouvola Homepage$/) do question = "Does the following home page open in the browser, http://www.nouvola.com?" answer = ask(question).chomp expect(answer).to eq "yes" end If you just tried to run the above code, you will most like have received an error. Given I am on the Nouvola Homepage # features/step_definitions/steps.rb:1 Does the following home page open in the browser, http://www.nouvola.com? yes expected: "yes" got: "yes\n" (compared using ==) (RSpec::Expectations::ExpectationNotMetError) ./features/step_definitions/steps.rb:4:in `/^I am on the Nouvola Homepage$/' features/nouvola.feature:4:in `Given I am on the Nouvola Homepage' This can be easily fixed by adding a chomp to the end of code. Given(/^I am on the Nouvola Homepage$/) do question = "Does the following home page open in the browser, http://www.nouvola.com?" answer = ask(question).chomp expect(answer).to eq "yes" end Now with the ask method, I can “fully” document my scenario. Feature: As A User, I would like to view my Nouvola Dashboard Scenario: I should see my dashboard when I log in Given I am on the Nouvola Homepage When I log into my account Then I see my dashboard And my code looks like this: Given(/^I am on the Nouvola Homepage$/) do question = "Does the following home page open in the browser, http://www.nouvola.com?" answer = ask(question).chomp expect(answer).to eq "yes" end When(/^I log into my account$/) do question1 = "When you click 'Login' from the top menu, are you taken to the login page?" question2 = "Are you able to enter your log in credentials and click on 'LOG IN' button?" answer = ask(question1).chomp expect(answer).to eq "yes" answer = ask(question2).chomp expect(answer).to eq "yes" end Then(/^I see my dashboard$/) do question = "Do you see your dashboard?" answer = ask(question).chomp expect(answer).to eq "yes" end Of course, this approach can easily get out of hand. In the next post, I'll demonstrate how I currently manage my manual steps. |