-
-
Save johnwards/833912 to your computer and use it in GitHub Desktop.
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 <study name>, <short url>, <welcome text> and set self registration to <self registration> | |
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 This is some welcome | |
Text | |
""" | |
| false| | |
| Study 1| study-1|""" | |
Hello This is some more | |
welcome | |
Text | |
""" | |
| true| |
Also, DON'T ever make "super-steps" like that:
When I enter <study name>, <short url>, <welcome text> and set self registration to <self registration>
Instead, split it to smaller one, so you could be able to reuse them in later scenarios:
When I enter <study name>
And enter <short url>
And enter <welcome text>
And set self registration to <self registration>
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.
You don't need to test all that text. What you're testing is Behavior, not templates or rendering!
What you need is be able to check that if you post some mocking fixture to form (''bla bla bla') - it will be saved. And if you have hello message - you don't need to check all that message to equality. You need to check only that this messages says hello to specific person. It means "Then I should see 'Hello, Mike'"
Remember, you're defining specification, not test! Think different, like with Apple.
Rather than: "I'm testing that this message must be", you're saying: "When user posts form wis his name, then the response should contain it"!