2012-12-06 20 views
0

我在尋找一些背景信息,發光功能情況之間的差異。什麼時候是一個功能,當情景

說,我有一個文件use_administration.feature

Feature: Use administration area 

    So that I can administrate the application 
    As an administrator 
    I can visit the administration area 

    Scenario: Get a login form 
    Given I am not logged in 
    When I visit the administration dashboard 
    Then I should see a login-form 

    Scenario: Access the Dashboard 
    Given I am not logged in 
    And there is a user "[email protected]" with password "password" 
    When I log in with username "[email protected]" and password "password" 
    Then I should see a dashboard 

我會考慮這些方案的很好定義。

然而,看着另一個Feature時,該問題變得更加清晰

Feature: Manage campings 

    So that a writer can manage her campings 
    As a logged in writer 
    I want to update and delete campings 

    Scenario: Logged in writer can create a new camping 
    Given I am administrator 
    And no campings on the campings listing 
    When I create a Camping named "Beautifull Green" 
    And I visit the "Campings" administration page 
    Then I should see a camping "Beautifull Green" 

    Scenario: Logged in writer sees own campings dashboard 
    Given I am administrator 
    And I have a camping "Beautifull Green" 
    When I visit the administration dashboard 
    Then I should see a panel titled "My Campings" 
    Then I should see camping "Beautifull Green" 

    Scenario: Logged in writer can update campings 
    Given I am administrator 
    And I have a camping "Beautifull Green" 
    When I visit the update page for "Beautifull Green" 
    And I update the name to "updated!" 
    And I visit the "Campings" administration page 
    Then I should see a camping "updated!" 

    Scenario: Logged in writer can update camping from dashboard 
    Given I am administrator 
    And I have a camping "Beautifull Green" 
    When I visit the administration dashboard 
    Then I should see the "edit"-link for "Beautifull Green" 

很多這些場景的重疊,因此或許應該已經特點的自己。請注意,重疊部分大多由共享步驟覆蓋。但仍然有很多重複。

我的主要問題是:什麼時候是某個功能,什麼時候是一個場景。任何經驗法則? 是否有良好的做法,有多少場景的功能應該包含?還是我完全誤解了整個話題?

回答

1

在我看來,這是關於現實生活中的組織技能。如果你能用簡單的英語來清楚地描述情景,那就夠了。

讓我們來檢查你的第二個功能。有很多問題。

  1. 什麼是用戶角色?作家或管理員?你在一個功能中提到了他們兩個。這是不可接受的。

  2. 說明格式有問題。這不正確的英語。它應該是:

    In order to keep my campaigns up to date 
    As a logged in writer 
    I want to manage my campaigns 
    

    As a logged in writer 
    I want to manage my campaigns 
    So that I can keep my campaigns up to date 
    

    這裏的一些注意事項

    • 您在方案中提到CRUD,但前面的描述是對更新和刪除只。
    • 「管理活動」不是商業目標,它是活動。所以我使用「讓我的廣告系列保持最新狀態」來取代它。
  3. 在場景中,有「給予我是管理員」和「我有野營'美麗綠色'」的重疊。這是不必要的。你應該使用Background來描述。例如:

    Background: 
        Given I have logged in as an Administrator 
        And I have a camping "Beautifull Green" 
    

    這些將爲您節省所有重複。如果你想測試Create,只需使用另一個名字,相同的「漂亮的紅色」。

  4. The Scenarios標題太長。不需要主題。您之前已經描述過用戶和背景。該標題是:

    Scenario: Create new campaign 
        # description here 
    Scenario: Update campaign 
        # ..... 
    

希望這些幫助。

+0

謝謝。除了你提出的所有優點(是的,這些都是建設中的功能,需要清理),我忽略了「背景」部分。這解決了我的主要問題。關於「商業目標」的部分也非常有用。我現在看到,我的特徵確實傾向於「活動」。謝謝。 – berkes

+0

@berkes,我很高興我的回答對你有一點幫助。 「商業目標」很有用,但有時候有點難以想象。其實我停了一會兒纔想到「管理活動」的目標是什麼:-)享受! –

相關問題