[QA] Best practices for long scenarios in Cucumber?

Nikolas Everett neverett at wikimedia.org
Tue Dec 17 21:42:40 UTC 2013


On Tue, Dec 17, 2013 at 4:26 PM, Jeff Hall <jhall at wikimedia.org> wrote:

> I want to create a browser test (for Visual Editor) that will repro a
> single continuous session where the user makes multiple edits to the same
> page.  As I understand it, Cucumber "Scenarios" each equate to a new user
> session, which is not what I want, so the alternative seems to be to
> construct a long, continuous scenario like the following:
>
>
>   Scenario:
>     Given I am logged in
>     When I am at my user page
>     And I click Edit for VisualEditor
>     And I insert the text "My first edit. "
>     And I click Save page
>     And I click This is a minor edit
>     And I click Review your changes
>     And I click Return to save form
>     And I click Save page the second time
>     Then Page should contain My first edit.
>
>     Given I click Edit for VisualEditor
>     When I insert the text "My second edit. "
>     And I click Save page
>     And I click Save page another time
>     Then Page should contain My second edit. My first edit.
>
>     <and on and on...>
>

You can build compound steps out of other steps.  I might suggest making a
step like
When(/^I insert (.*)( as a minor edit)$/ do |text, minor_edit|
  ruby code here that does what you want
or
  step('When I am at my user page')
  step('And I click Edit for VisualEditor')
  ...
or
  steps %Q{
    When I am at my user page
    And I click Edit for VisualEditor
  }
end

The second two implementations are somewhat debated.  Some cucumber folks
hate steps calling steps and some love it.  I'm can see merit in both
arguments.

Nik
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.wikimedia.org/pipermail/qa/attachments/20131217/ac8dcbc3/attachment.html>


More information about the QA mailing list