Page MenuHomePhabricator

Group Cucumber step definitions by type, and sort steps in a group alphabetically
Closed, ResolvedPublic

Description


Version: unspecified
Severity: normal
Whiteboard: gci2013 https://www.mediawiki.org/wiki/Google_Code-In#Candidate_tasks

Details

Reference
bz49876

Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 22 2014, 1:41 AM
bzimport set Reference to bz49876.

Cucumber step definitions[1] should be sorted alphabetically. This is how a definition looks like:

step_type(/^step name$/) do

  1. ruby code

end

Example (from visual_editor_steps.rb[2]):

Given(/^I am at my user page$/) do

visit(VisualEditorPage)

end
When /^I click Save page$/ do

on(VisualEditorPage).save_page_element.click

end
Then /^Page text should contain the string$/ do

@browser.text.should match Regexp.escape("Editing with #{@does_not_exist_page_name}")

end

Ruby code should be ignored. Steps should be grouped by type. "Given" steps should be grouped together, the same for "When" and "Then" steps. Inside the group, steps should be sorted alphabetically by step name.

For a good example on how steps should be grouped and sorted see aftv5_steps.rb[3] file.

1: https://github.com/wikimedia/qa-browsertests/tree/master/features/step_definitions
2: https://github.com/wikimedia/qa-browsertests/blob/master/features/step_definitions/visual_editor_steps.rb
3: https://github.com/wikimedia/qa-browsertests/blob/master/features/step_definitions/aftv5_steps.rb

Jeff, I have just noticed this bug and thought it would be a good task for code-in. :)

Since this is an easy task, I would suggest that it is done for all our repositories (about 10 of them) that contain step files[1]

1: https://github.com/wikimedia/mediawiki-selenium#links

I have just noticed that you are using this bug as documentation, please ignore the comment above.

maddiemadan wrote:

The [2] link is no longer working as the file has been removed from the repository

If you need more information (and you probably do), feel free to ask questions
here, at #wikimedia-qa freenode IRC channel or at QA mailing list:

https://lists.wikimedia.org/mailman/listinfo/qa

Reopening, this bug is about implementing the convention, not documenting it. :)

Now that we have the document, I plan to update it and then we can have another task to implement the convention across all repositories.