[英]I am working with the BDD framework, and I have very large scenarios with many examples
我正在使用 BDD 框架,並且我有很多示例(測試數據)的非常大的場景。 我怎樣才能最小化這些示例和場景以使其更易於維護?
或者我如何從 excel 表中讀取我的示例(測試數據)而不是在功能文件中實現所有示例。 這是好的解決方案嗎?
我目前正在做的是在我的功能文件中實現所有示例,盡管事實上在某些情況下,我有超過 20 列的示例,這些示例很難定期更改和維護。
像這樣的東西。
Scenario Outline: success renewal MI bundle
Given msisdn "<msisdn>" is active on service class id "<serviceClass>"
And msisdn "<msisdn>" has balance equal "<miFees>"
And delete all offers from msisdn "<msisdn>"
And msisdn "<msisdn>" has bundle id "<Offer1>" opted in with offer2"<offer2>"
And msisdn "<msisdn>" has usage "<usage1>" with usage "<usage2>" and usage threshold id "<usageThresholdId>"
And dedicated id "<dedicted1>" updated for msisdn "<msisdn>" with dedicated value "<dedicated2>"
And msisdn "<msisdn>" has balance equal "<balance>"
And msisdn "<msisdn>" has offer id "<offer1>" with validity duration "<validityToday>"
And msisdn "<msisdn>" has dummy offer
When pamID "<pam>" runs for msisdn "<msisdn>" while having "<offer1>"
Then validate msisdn "<msisdn>" has offer with offer id "<offer1>"
And validate msisdn "<msisdn>" has offer id "<offer1>" with validity duration "<validityDuration>"
And validate msisdn "<msisdn>" has offer with offer id "<offer2>"
And validate msisdn "<msisdn>" has offer id "<offer3>" with validity duration "<validityDuration>"
And validate that msisdn "<msisdn>" balance should be equal "<balanceAfter>"
And validate that msisdn "<msisdn>" has product id "<product1>" and quota name "<quotaName>" and max quota should be "<maxQuota>"
And validate that msisdn "<msisdn>" has product id "<offer3>" and quota name "<rolloverQuotaName>" and max quota should be "<rolloverQuota>"
And validate msisdn "<msisdn>" has dedicated id "<dedicated1>" with dedicated value "<dedicatedValue1>"
And validate msisdn "<msisdn>" has dedicated id "<dedicated2>" with dedicated value "<dedicatedValue2>"
Examples:
| msisdn | serviceClass | balance | validityDuration | offer1 | offer2 | usage1 | usage2 | usageThresholdId | validityToday | pam | offer3 | balanceAfter | product1 | quotaName | maxQuota | rolloverQuota | rolloverQuotaName | dedicated1 | dedicatedValue1 | dedicated2 | dedicatedValue2 |
| xx | xxx | xx | xx | xx | | xx | xx | xx | xx | xx | xxx | xxxx | xxxxx | x | xx | xxx | xx | xx | xxx | xx | xx |
所以您正在使用 BDD 框架。 BDD 的目標之一是領域專家可以理解規范。
這意味着功能文件相對獨立。 它們應該包含人們理解某項功能所需的一切。 從 Excel 讀取數據會破壞該遏制。 所以你不會找到太多支持。
現在您可以重寫您的方案以不需要這些標識符。 但是我不能完全弄清楚你實際測試的是什么來給你一個很好的例子。 嘗試用簡單的文字寫下您正在測試的內容。
現在也許您過去已經這樣做了。 而且我將不得不猜測讓您編寫這樣的場景的情況。 但是您可能必須返回 go 並解決這些問題,而不是解決這些問題。
要么改變為更多數據驅動的框架。 Spock浮現在腦海中。
Cucumber 最適合用來描述您在做什么以及為什么它很重要。 詳細說明如何完成某事要糟糕得多。 為了使您的場景更好,您需要push the how down
。 為此,我建議如下
Scenario: Login
Given I am registered
When I view the login page
And I fill in my email with fred@example.com
And I fill in my password with password
And I click the login button
你有
Scenario: Login
Given I am registered
When I login
Then I should be logged in
我是誰、我如何登錄、我如何注冊等的所有細節都被下推到步驟定義中(理想情況下甚至下推到這些步驟定義的輔助方法中)。
這將是一項艱巨的工作,因為您必須真正了解您在做什么以及為什么它很重要,並且可能必須提出一些困難的問題才能獲得這種理解。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.