我們是新的bdd /黃瓜和討論在隊伍中如何編寫正確的功能/場景。最好的做法,寫真正的bdd黃瓜功能/場景
我們想出了兩個下列辦法,幾乎應該說明/解決同樣的要求:
Feature: Give access to dossiers to other registered users
As a logged in user
In order to show my dossier to other users
I want to give other users (limited) access to my dossiers
Background:
Given I am logged in as "Oliver"
And another user "Pascal" exists
And another user "Tobias" exists
Scenario: I can give access to my own dossier
When I grant access to "Pascal" with permisson "readonly"
Then I should see "Access granted."
And user "Pascal" should have permission "readonly" on dossier "Oliver"
Scenario: I can give access to a created dossier
Given I created a new dossier "Max Müller"
When I grant access on dossier "Max Müller" to "Pascal" with permisson "readonly"
Then I should see "Access granted."
And user "Pascal" should have permission "readonly" on dossier "Max Müller"
Scenario: I can give access to a managed dossier
Given I manage the dossier from "Tobias"
When I grant access on dossier "Tobias" to "Pascal" with permisson "readonly"
Then I should see "Access granted."
And user "Pascal" should have permission "readonly" on dossier "Tobias"
Scenario: I cannot give access to a writable dossier
Given I have write access to the dossier from "Tobias"
When I follow "Grant access"
Then I should see "You are not allowed to grant access on this dossier."
Scenario: I cannot give access to a readonly dossier
Given I have readonly access to the dossier from "Tobias"
When I follow "Grant access"
Then I should see "You are not allowed to grant access on this dossier."
Scenario: I can give access to a dossier with an expiration date
Given I created a new dossier "Max Müller"
When I grant access on dossier "Max Müller" to "Pascal" with permisson "readonly" until "2020-01-01"
Then I should see "Access granted till 2020-01-01."
And user "Pascal" should have permission "readonly" on dossier "Max Müller" until "2020-01-01"
Scenario: I cannot transfer a created dossier to a new owner who is already registered
Given I created a new dossier "Max Müller"
When I transfer dossier "Max Müller" to "Pascal"
Then I should see "Pascal already has a dossier, transfer not possible."
第二個:
Feature: Grant access on dossiers to registered users
As a logged in user
In order to allow others to view/ manage dossiers I have access to
I want to give access of those to other users
Background:
Given I am logged in as "[email protected]"
And I am working with my own dossier
Scenario: Invalid data entered
When I visit the grant dossier access page
And I press "Grant access"
Then I should see a validation error on "eMail-Address"
Scenario: Valid data entered
Given a user "[email protected]" exists
When I visit the grant dossier access page
And I fill in "eMail-Address" with "[email protected]"
And I select "readonly" from "Permissions"
And I press "Grant access"
Then I should see "Access granted."
And I should be on the dossiers page
Scenario: Valid data entered with expiry date
Given a user "[email protected]" exists
When I visit the grant dossier access page
And I fill in "eMail-Address" with "[email protected]"
And I select "readonly" from "Permissions"
And I fill in "Valid until" with "2010-03-01"
And I press "Grant access"
Then I should see "Access granted till 2010-03-01."
And I should be on the dossiers page
Scenario: Display calendar on click on "Valid until"
When I click on the field "Valid until"
Then a calendar popup should be displayed
When I click on "1943-01-02"
Then the field "Valid until" should be have "1943-01-02"
And the calendar popup should be hidden
Scenario: Only allow to grant access to categories I have access to myself
Given I have limited access to the working dossier
When I visit the grant dossier access page
Then I should not see categories I have no access to
Scenario: Dossier with permission "manager" can only grant readonly, readwrite
Given I have the permission "manager" on my working dossier
When I visit the grant dossier access page
Then I should only see the permissions "readonly, readwrite"
Scenario: Dossier with permission "readwrite" is not allowed to grant any permissions
Given I have the permission "readwrite" on my working dossier
When I visit the grant dossier access page
Then I should the see the error "You cannot grant access on this dossier!"
And I should be on the dossiers page
一個你會喜歡哪一種?爲什麼?
有點讓人從死裏復活,但是有沒有一個理由,你還沒有選擇一個答案呢?無論如何,你最終會做什麼?它是如何發揮作用的? – KobeJohn 2012-01-16 16:28:05