2012-03-04 37 views
4
Scenario: Change a member to ABC 60 days before anniversary date 
    Given Repeat When+Then for each of the following IDs: 
    | ID   | 
    | 0047619101 | 
    | 0080762602 | 
    | 0186741901 | 
    | 0311285102 | 
    | 0570130101 | 
    | 0725968201 | 
    | 0780265749 | 
    | 0780265750 | 
    | 0780951340 | 
    | 0780962551 | 
#----------------------------------------------------------------------- 
    When these events occur: 
    | WorkflowEventType | WorkflowEntryPoint | 
    | ABC     | Status Change  | 
    Then these commands are executed: 
    | command name  | 
    | TerminateWorkflow | 
    And For Member, the following documents were queued: 
    | Name  | 
    | ABC Packet | 

在上述情況下,我想:SpecFlow - 用列表重複測試X次?

  • GIVEN - 查找從DB
  • 10成員時,+ THEN - 操作步驟10次,一次爲每個記錄。

SpecFlow有可能嗎?
如果是這樣,你會如何設置它?

TIA

回答

6

這實際上很容易做到,儘管文檔需要一些搜索。

你想要的是一個場景輪廓,像這樣:

Scenario Outline: Change a member to ABC 60 days before anniversary date 
Given I have <memberId> 
When these events occur: 
    | WorkflowEventType | WorkflowEntryPoint | 
    | ABC     | Status Change  | 
Then these commands are executed: 
    | command name  | 
    | TerminateWorkflow | 
And For <memberId>, the following documents were queued: 
    | Name  | 
    | ABC Packet | 

Examples: 
    | memberId | 
    | 0047619101 | 
    | 0080762602 | 
    | 0186741901 | 
    | ...etc... | 

這將再次執行您的方案在實例表中的每個ID。如果需要,您可以擴展該表以具有多個列。

,或者更簡單(如果你真的只有在上述每個示例表中的一行)

Scenario Outline: Change a member to ABC 60 days before anniversary date 
Given I have <memberId> 
When A 'ABC' Event Occurs with EntryPoint 'Status Change' 
Then a TerminateWorkflow command is executed 
And For <memberId>, the 'ABC Packet' document was queued 

Examples: 
    | memberId | 
    | ...etc... | 

欲瞭解更多信息,請參閱specflow-wiki on githubcucumber language syntax for scenario outlines

+0

感謝。我終於找到了這個小塊頭,真是太棒了! – 2012-03-05 17:29:04

+0

另外,我們使用表格來幫助使輸入更易變。我們可能有100個這種一般形式的測試,有些則採用多線輸入(在表中),而另一些則是單線。再次 - 謝謝! – 2012-03-05 17:31:01