用 @wip (工作进行中)标签标记你未完成的场景。这些场景不纳入考虑,且不标记为测试失败。当完成一个未完成场景且功能测试通过时,为了把此场景加至测试套件里,应该移除 @wip 标签。
配置你的缺省配置文件,排除掉标记为 @javascript 的场景。它们使用浏览器来测试,推荐停用它们来增加一般场景的执行速度。
替标记著 @javascript 的场景配置另一个配置文件。
配置文件可在 cucumber.yml 文件里配置。
# 配置文件的定义: profile_name: --tags @tag_name
带指令运行一个配置文件:
cucumber -p profile_name
若使用 fabrication 来替换假数据 (fixtures),使用预定义的 fabrication steps。
不要使用旧版的 web_steps.rb 步骤定义!最新版 Cucumber 已移除 web steps,使用它们导致冗赘的场景,而且它并没有正确地反映出应用的领域。
当检查一元素的可视文字时,检查元素的文字而不是检查 id。这样可以查出 i18n 的问题。
给同种类对象创建不同的功能特色:
# 差 Feature: Articles # ... 功能实作 ... # 好 Feature: Article Editing # ... 功能实作 ... Feature: Article Publishing # ... 功能实作 ... Feature: Article Search # ... 功能实作 ...
每一个功能有三个主要成分:
Title
Narrative - 简短说明这个特色关于什么。
Acceptance criteria - 每个由独立步骤组成的一套场景。
最常见的格式称为 Connextra 格式。
In order to [benefit] ... A [stakeholder]... Wants to [feature] ...
这是最常见但不是要求的格式,叙述可以是依赖功能复杂度的任何文字。
自由地使用场景概述使你的场景备作它用 (keep your scenarios DRY)。
Scenario Outline: User cannot register with invalid e-mail When I try to register with an email "<email>" Then I should see the error message "<error>" Examples: |email |error | | |The e-mail is required| |invalid email |is not a valid e-mail |
场景的步骤放在 step_definitions 目录下的 .rb 文件。步骤文件命名惯例为 [description]_steps.rb。步骤根据不同的标准放在不同的文件里。每一个功能可能有一个步骤文件 (home_page_steps.rb)
。也可能给每个特定对象的功能,建一个步骤文件 (articles_steps.rb)。
使用多行步骤参数来避免重复
场景:
User profile Given I am logged in as a user "John Doe" with an e-mail "user@test.com" When I go to my profile Then I should see the following information: |First name|John | |Last name |Doe | |E-mail |user@test.com| # 步骤: Then /^I should see the following information:$/ do |table| table.raw.each do |field, value| find_field(field).value.should =~ /#{value}/ end end
使用复合步骤使场景备作它用 (Keep your scenarios DRY)
# ...
When I subscribe for news from the category "Technical News"
# ...
# 步骤:
When /^I subscribe for news from the category "([^"]*)"$/ do |category|
steps %Q{
When I go to the news categories page
And I select the category #{category}
And I click the button "Subscribe for this category"
And I confirm the subscription
}
end
总是使用 Capybara 否定匹配来取代正面情况搭配 should_not,它们会在给定的超时时重试匹配,允许你测试 ajax 动作。 见 Capybara 的 读我文件获得更多说明。
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
P70系列延期,华为新旗舰将在下月发布
3月20日消息,近期博主@数码闲聊站 透露,原定三月份发布的华为新旗舰P70系列延期发布,预计4月份上市。
而博主@定焦数码 爆料,华为的P70系列在定位上已经超过了Mate60,成为了重要的旗舰系列之一。它肩负着重返影像领域顶尖的使命。那么这次P70会带来哪些令人惊艳的创新呢?
根据目前爆料的消息来看,华为P70系列将推出三个版本,其中P70和P70 Pro采用了三角形的摄像头模组设计,而P70 Art则采用了与上一代P60 Art相似的不规则形状设计。这样的外观是否好看见仁见智,但辨识度绝对拉满。