我已經得到的specflow測試屈指可數的步驟,是這個樣子:我應該如何命名我的一個場景輪廓
Scenario: Person is new and needs an email
Given a person
And the person does not exist in the repository
When I run the new user batch job
Then the person should be sent an email
Scenario: Person is not new and needs an email
Given a person
And the person does exist in the repository
When I run the new user batch job
Then the person should not be sent an email
除,而不是僅僅2的情況,我有10級非常相似的場景,所有的步驟都是這樣,所以我想使用「場景大綱」。不幸的是,我很難用一種可讀的方式來重寫我的步驟。
目前,我已經想出了這一點,但看起來笨重:
Scenario: Email batch job is run
Given a person
And the person '<personDoes/NotExist>' exist in the repository
When I run the new user batch job
Then the person '<personShould/NotGetEmail>' be sent an email
Examples:
| !notes | personDoes/NotExist | personShould/NotGetEmail |
| Exists | does not | should |
| No Exist | does | should not |
我也認爲是本,而它是清潔不達意近也
Scenario: Email batch job is run
Given a person
And the person does exist in the repository (is '<personExist>')
When I run the new user batch job
Then the person should be sent an email (is '<sendEmail>')
Examples:
| !notes | personExist | sendEmail |
| Exists | false | true |
| No Exist | does | false |
有沒有人有更好的參數化方法,如「是」,「不」,「應該」,「不應該」,「有」,「沒有」?在這一點上,我正在考慮把所有東西都作爲一個不同的場景,因爲它更具可讀性。
你目前有10個測試...看起來並不像很多,除非測試本身有很多步驟 - 如果它們確實有很多繁瑣的步驟,我們可能能夠將測試按摩成形,以便表格和場景概述變得過度。你可能會發佈一個實際測試作爲一個例子(最複雜的測試?),並突出變體測試中的變化? – perfectionist 2012-01-28 07:54:12