cumumber参数说明

feature文件

1. Feature

用来描述我们需要测试的模块,如登录模块

2. Scenario

用来概述功能测试点,如登录功能接口.登录验证功能接口

3. Given

前置条件,比如用户已有账号,用户在哪个页面进行操作?

4. When

描述用户操作的执行动作,比如请求某个api

5. Then

断言 表示执行的结果

6. And

一个步骤中如果存在多个Then操作,第二个开始后面的Then可以用And替代(注意是可以,也可以用Then),使用but比起when仅仅是让语义阅读起来更好理解

7. But

测试中效果与And一样

8. Scenario outline

与Examples配合使用,测试Examples每一行数据

9. Examples

定义测试数据表,第一行是字段名,与Given,When,Then里参数一一对应

10. background

如果有多个案例中存在重复的given and ,可以使用backfround进行替换,就是提前公共部分,例如

11. 井号#

注释

#语句中参数写法
Feature: faceBook login

Scenario Outline: Login functionality for a social net working site.
  Given user navigates to Facebook
  When I enter Username as "<username>"
  And Password as "<password>"
  Then login should be unsuccessful
  Then check status "<status>"
  Then check msg "<msg>"

  @test1
  Examples:
    |Scenario | username | password     | msg      | status |
    |test1    | a        | 123456       | success  | 0000   |
    |test2    | b        | 123456       | success  | 0000   |
    |test3    | b        | 123456       |          | 0000   |
    |test4    | b        | 123456       | null     | 0000   |

  @test2
  Examples:
    |Scenario | username  | password     | msg      | status |
    |test1    | ac        | 123456       | success  | 0000   |
    |test2    | bc        | 123456       | success  | 0000   |
    |test3    | bx        | 123456       |          | 0000   |
    |test4    | bc        | 123456       | null     | 0000   |

  @test3
  @test1
  Examples:
    |Scenario | username  | password     | msg      | status |
    |test1    | acv       | 123456       | success  | 0000   |
    |test2    | bcb       | 123456       | success  | 0000   |
    |test3    | bvc       | 123456       |          | 0000   |
    |test4    | bvn       | 123456       | null     | 0000   |

步骤定义类

1. @Given,@When,@Then

与feature里的步骤一一对应

2. @And@But

与上一个@注解相同的意思

3. 传参,参见官网

Parameter TypeDescription{int}Matches integers, for example 71 or -19{float}Matches floats, for example 3.6, .8 or -9.2{word}Matches words without whitespace, for example banana (but not  banana split){string}Matches single-quoted or double-quoted strings, for example "banana split" or 'banana split' (but not banana split). Only the text between the quotes will be extracted. The quotes themselves are discarded. Empty pairs of quotes are valid and will be matched and passed to step code as empty strings.{}anonymousMatches anything (/.*/).


运行文件

1. @RunWith(Cucumber.class)

指明这是Cucumber测试运行文件

2. @CucumberOptions

用途默认值备注features定义查找feature文件的路径falseglue定义步骤文件java类的路径{}验证时发现不指定会主动查找run文件同一目录下dryRun会先检查所有步骤是否都有定义falsemonochrome以可读的方式显示控制台输出falsestrict如果存在未定义或挂起的步骤,则执行失败falsetags指定运行测试的feature中tag{}tags = {"@test1,@test3"}是or的意思,满足一个则允许tags = {"@test1","@test3"}是"and",满足两个才运行plugin指定生成报告{}plugin = {"pretty","html:target/cucumber","json:target/cucumber.json"}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值