cucumber学习笔记8

上一篇 / 下一篇  2013-08-28 16:46:09

cucumber command-line:

cucumber --tags @focus,@email
运行含有@focus tag或者@email tag的场景

cucumber --tags @fast --tags @focus,@email
运行含有@fast tag并且有@focus tag或者有@email tag的场景

cucumber --tags ~@fast --tags @focus,~@email
运行不包含@fast tag并且包含@focus tag或者不包含email tag的场景

设置找到tag数量的上限:
cucumber --tags @slow:10
# Execute all scenarios tagged with @slow, failing if more than ten are found.
超过10个@slow场景被找到,将会fail

cucumber XXX.feature:11或cucumber xxx.feature --line 11
运行 XXX.feature第11行的场景

cucumber XXX.feature:11:32或cucumber XXX.feature --lines 11 --lines 32
运行 XXX.feature第11行和第32的场景

cucumber --name "scenarioname"
运行名称为scenarioname的场景

cucumber --exclude "scenarioname#???
排除名称为scenarioname的场景

Changing Cucumber’s Output:

cucumber --format progress
..U--..F..
Each character represents the status of each step:
.表示通过
U表示undefined
-表示skipped(或者是一个Scenario Outline step).
F表示失败

cucumber -f rerun
如果有场景失败,将会输出它所在的位置例如:features\adding.feature:9:10

Formatting to File and Using Multiple Formatters:

cucumber -f pretty -f html --out cukes.html -f rerun --out rerun.txt

以上命令将html格式的输出写入cukes.html文件,并且将rerun格式的输出写入rerun.txt文件,同时在console里返回pretty格式的输出。注意,最多只有一个格式可以在console里输出,如果有多个格式输出,其他输出要用--out参数去写入文件,否则报错。但可以将所有输出都用--out写入文件

cucumber --backtrace(或直接用-b)

backtrace参数可以将每个failure的backtrace输出,是用来debug的

cucumber --require(或直接用-r)
-r指定了require的文件目录
假定目录结构如下:
features
├── billing
│   └── credit_card.feature
├── scoring
│   ├── multi_player.feature
│   └── single_player.feature
└── step_definitions
    ├── billing_steps.rb
    └── scoring_steps.rb
假设在根目录直接运行cucumber features或cucumber,那么没有问题
如果运行cucumber features/billing或features/billing/credit_card.feature
则会提示相应的step_definition未定义,这是由于指定运行feature文件或目录时,cucumber默认会在它同级(如果是文件)或下级目录(如果是目录)寻找对应的step definition或support code,可以通过--verbose查看cucumber在何处寻找。
解决办法是用--require参数
cucumber features/billing --require features
现在则会去feature目录下找
step definition或support code


Work in Progress (WIP)
对待完成的场景打上@wip标签

cucumber --wip @wip:3

如果未完成的场景超过3个,直接fail,如果有任何场景pass,则fail,这是为了提醒我们把已经通过的场景移除@wip标签。


使用Profiles存储comand line:
建立一个cucumber.yml文件,放在根目录(与features文件叫同级)或者根目录/config目录下,以下是例子:
default: --tags ~@wip --require features
wip: --tags @wip:3 --wip --require features
(注意,命令里不需要再写cucumber了)
现在,如果运行cucumber --profile wip
则会运行cucumber --tags @wip:3 --wip --require features
如果运行不传--profile参数,则会运行default的内容

输入的命令与--profile的内容会叠加,例如:
cucumber --verbose
则会同时执行verbose参数和default的内容。
即等于输入了cucumber --verbose --tags ~@wip --require features



TAG:

 

评分:0

我来说两句

我的栏目

日历

« 2024-05-02  
   1234
567891011
12131415161718
19202122232425
262728293031 

数据统计

  • 访问量: 31881
  • 日志数: 22
  • 建立时间: 2013-08-19
  • 更新时间: 2014-04-01

RSS订阅

Open Toolbar