Created
February 18, 2011 16:25
-
-
Save johnwards/833912 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Feature: New Study | |
In order to create a new Study | |
As a Researcher | |
I must be able to enter information about the study and save it | |
Scenario Outline: Researcher adds new study | |
When I enter a study name of <study name> | |
And I enter a short url of <short url> | |
And I enter a some welcome text of <welcome text> | |
And I set self registration to <self registration> | |
When I press "Add study" in user form | |
Then I should be redirected to /study/list | |
And I should see "New Study <study name> created" | |
Examples: | |
|study name|short url|welcome text|self registration| | |
| Study 1| study-1|Hello some text| false| | |
| Study 2| study2|This is a study| true| | |
Scenario: Adding an image to a new study | |
When I enter a study name of Study with Image | |
And I enter a short url of study-test | |
And I enter a some welcome text of Hello this is a study | |
And I set self registration to false | |
And I upload an image called logo.png | |
When I press "Add study" in user form | |
Then I should be redirected to /study/list | |
And I should see "New Study Study with Image created" |
Right so if I am doing newline formatting with say nl2br() and want to confirm that it is being outputted correctly then I can't do this with Behat?
I am not actually going to write a test for this, but just curious.
Also I might want to stick a lot of markdown in etc, like some of your examples.
BDD is new to me, I come from lime unit and functional tests so just feeling my way around.
Test tiny behavior parts, rather than all possible variants. Need to test nl2br() in your form? Write scenario for that only:
Scenario: Message with newline
Given I am on the "..." page
When I enter:
"""
some text
with newline
"""
And I hit "save"
Then I should see:
"""
some text <br/> with newline
"""
See? You test tiny single scenario - message with newline. And when it works - you can write another scenario about another tiny feature (new study in your case). Don't mess all in one place. Remember 2 main principles:
- DRY - break your scenarios and tests into as small parts as possible, to be able to reuse things later
- CLN (clean) - keep things clean, test 1 tiny behavior at once, not bunch of different behaviors.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Also, DON'T ever make "super-steps" like that:
Instead, split it to smaller one, so you could be able to reuse them in later scenarios: