gpt4 book ai didi

ruby-on-rails - Rails - Cucumber 场景中的 DRY。什么是好的平衡?

转载 作者:行者123 更新时间:2023-12-04 05:50:49 27 4
gpt4 key购买 nike

我有以下场景:

Scenario: Create a game with valid information
Given I am logged in
When I visit the new game page
And I fill in "Game type" with "Basketball"
And I fill in "Zip code" with "94040"
And I fill in "Description" with "Friendly match"
And I click on the button "Create Game"
Then I should see "Awesome! Your game has been created."

Scenario: Create a game with missing information
Given I am logged in
When I visit the new game page
And I fill in "Zip code" with "94040"
And I fill in "Description" with "Friendly match"
And I click on the button "Create Game"
Then I should see "Game type can't be blank."

如您所见,我正在重复代码并作为 开发商从这个角度来看,我讨厌在两种情况下都重复一些句子。但是,我假设场景必须是独立清晰的,所以任何 利益相关者 可以看看然后说..哦,我知道这个场景描述的是什么。

我正在尝试测试我的表单验证对于不同类型的字段值是否正常工作。所以,我会有很多类似的场景,基本上都会改变“ ”部分。因此,另一个类似/相关的场景是检查邮政编码必须是数字的场景:
Scenario: Create a game with invalid zip code
Given I am logged in
When I visit the new game page
And I fill in "Game type" with "Basketball"
And I fill in "Zip code" with "ffff"
And I fill in "Description" with "Friendly match"
And I click on the button "Create Game"
Then I should see "Zip code has to contain 5 digits."

所以,我的问题是:有没有 ,商界人士友好的做法是什么?我的意思是,在代码优化和清晰易懂的独立场景定义之间取得平衡?

最佳答案

我想 scenario outline会很适合你。

关于ruby-on-rails - Rails - Cucumber 场景中的 DRY。什么是好的平衡?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10068680/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com