第一个方案是作为功能文件 registration.feature(feature1)的一部分运行,并具有以下内容:
Scenario: User can register as a Free account Given I am on the home page When I navigate to the Register page And set all required fields for "Free" on the page And check that info about successful registration is shown And activate account Then I copy the Free user information in a data file
然后我想在 upgrade_accounts.feature(feature2)
下运行以下功能Feature: Upgrade accounts As an QA Engineer I would like to upgrade my accounts to other types So I can make sure upgrade functionality is working properly Scenario: Existing free account is upgraded to premium Given I navigate to the login page When Sign in as free account retrieved from file And I navigate to updgrade accounts And I select premium account and submit Then Verify premium package is active
我的担忧是关于如何使用适用于步骤的内容实现这两个功能之间的连接:来自feature1的Then I copy the Free user information in a data file
和来自feature2的When Sign in as free account retrieved from file
。
所以我想问题是:最好使用哪种方法(gem)将数据从网页复制到文件中并阅读并再次使用它?
谢谢!
答案 0 :(得分:1)
通常,不鼓励在功能文件之间创建依赖关系。您希望能够使用确定性结果独立运行要素,因此通过状态耦合要素可能会产生脆弱(且易碎)的特征。例如,如果不执行upgrade_accounts.feature
,则无法成功执行registration.feature
。
如果您还没有找到The Cucumber Book,那么这是一个很好的指南和资源。它建议在挂接/support/hooks.rb
答案 1 :(得分:1)
Scenario: User can register as a Free account
Given I am on the home page
When I register for a free account
Then I get a message that registration is successful
And my account is active
Scenario: Existing free account is upgraded to premium
Given I have a free account
When I updgrade my account to a premium account
Then my premium package is active
两个功能,两个完全独立的测试。如果您只有一个步骤将免费帐户注入系统鉴于我有一个免费帐户,您最终将无法升级,因为注册免费帐户的步骤失败。 / p>
此外,我冒昧地减少了创建和验证帐户的步骤。在场景中不需要所有导航等。这是在步骤定义中完成的。