Ruby on rails 自动测试用户';她的年龄每年都在下降
我想用cucumber测试Rails应用程序用户的年龄。特征定义看起来有点像下面这样Ruby on rails 自动测试用户';她的年龄每年都在下降,ruby-on-rails,ruby,unit-testing,cucumber,Ruby On Rails,Ruby,Unit Testing,Cucumber,我想用cucumber测试Rails应用程序用户的年龄。特征定义看起来有点像下面这样 Scenario: Successful calculation of age Given I set my date of birth to "1987-07-15" Then my age should be "22" 上述功能定义每年都会失败,因为用户年龄每年会增加一岁 一种解决方案是将出生日期动态设置为22.5年前。但我不知道如何在小黄瓜(cucumber feature definition
Scenario: Successful calculation of age
Given I set my date of birth to "1987-07-15"
Then my age should be "22"
上述功能定义每年都会失败,因为用户年龄每年会增加一岁
一种解决方案是将出生日期动态设置为22.5年前。但我不知道如何在小黄瓜(cucumber feature definition language,黄瓜特征定义语言)中做到这一点
对此有何看法?我将添加另一个类似于此的给定条件
Scenario: Successful calculation of age
Given I set my date of birth to "1987-07-15" And the Date is "15/07/2010"
Then my age should be "22"
我将添加另一个与此类似的给定条件
Scenario: Successful calculation of age
Given I set my date of birth to "1987-07-15" And the Date is "15/07/2010"
Then my age should be "22"
你可以直接写
Scenario: Successful calculation of age
Given I set my date of birth to "22" years ago
Then my age should be "22"
并根据前22个参数自己进行日期转换(例如,将Fixnum参数改为测试方法,而不是日期)。但老实说,我可能会选择伊恩的方法。你可以直接写
Scenario: Successful calculation of age
Given I set my date of birth to "22" years ago
Then my age should be "22"
并根据前22个参数自己进行日期转换(例如,将Fixnum参数改为测试方法,而不是日期)。但老实说,我可能会支持伊恩的方法