CodeceptJS学习笔记-高级用法03-tag

 

附加@tag到您的测试名称

Scenario('update user profile @slow')


或者,使用tag场景的方法来设置其他标签:

Data(function*() {
    yield { login: '17600000000',password: '12345678'};
    yield { login: '13500000000',password: '12345678'};
  }).Scenario('test something', (I,current) => {
    //在浏览器打开页面
    I.amOnPage('/user/login')
    I.wait(10)
    //输入用户名密码
    I.fillField({css:'.ant-input-affix-wrapper .ant-input:not(:first-child)'},current.login)
    I.fillField({css:'.ant-input-affix-wrapper .ant-input:not(:last-child)'},current.password)
    // 点击登录按钮
    I.click('button, html [type="button"]')
    //截图
}).tag('@slow').tag('important');

运行命令

codeceptjs run --grep @slow

运行结果

CodeceptJS v2.6.5
Using test root "E:Docoumentcodeceptdemo"
 
loginaccount --
  √ test something | {"login":"17600000000","password":"12345678"} @slow @important in 35849ms
  √ test something | {"login":"13500000000","password":"12345678"} @slow @important in 32792ms
 
  OK  | 2 passed   // 1m

使用正则表达式进行更灵活的过滤:

  • --grep '(?=.*@smoke2)(?=.*@smoke3)' -以名称@ smoke2和@ smoke3运行测试
  • --grep "@smoke2|@smoke3" -以名称@ smoke2或@ smoke3运行测试
  • --grep '((?=.*@smoke2)(?=.*@smoke3))|@smoke4' -以名称(@ smoke2和@ smoke3)或@ smoke4运行测试
  • --grep '(?=.*@smoke2)^(?!.*@smoke3)' -使用@ smoke2运行测试,但名称中没有@ smoke3
  • --grep '(?=.*)^(?!.*@smoke4)' -运行除@ smoke4以外的所有测试
 
原文地址:https://www.cnblogs.com/7047-zfy/p/13232222.html