.skip() 和 .only() 的使用

.skip() 和 .only() 的使用

说明
  • 在做自动化测试中,跳过执行 某些测试用例,或只运行某些指定的测试用例,这种情况是很常见的
  • Cypress中也提供了这种功能
如何跳过测试用例

通过describe.skip() 或者 context.skip() 来跳过不需要执行的测试套件

复制代码
describe('ship test',()=>{
    describe.skip('跳过该测试套件',()=>{
        it('测试1',()=>{
            cy.log('测试用例1被执行');
        })
    })
})

通过 it.skip() 来跳过不需要执行的测试用例

typescript 复制代码
it.skip('测试用例2',()=>{
        cy.log('测试用例2');
});
指定执行测试套件或测试用例

当存在 .only() 指定某个测试套件或测试用例时,只有这个测试套件或测试用例会被执行 ,其他未加 .only() 的测试套件或测试用例都不会执行

通过 describe.only() 或者 context.only()来指定需要执行的测试套件

测试代码
typescript 复制代码
describe('only suite',()=>{
    context('suite1',()=>{
        it('case1',()=>{
            cy.log('case1');
        })
        it('case2',()=>{
            cy.log('case2');
        })
    })

    context.only('suite2',()=>{
        it('case3',()=>{
            cy.log('case3');
        })
        it('case4',()=>{
            cy.log('case4');
        })
    })

    context('suite3',()=>{
        it('case5',()=>{
            cy.log('case5');
        })
        it('case6',()=>{
            cy.log('case6');
        })
    })
})

通过 it.only() 来指定需要执行的测试用例

typescript 复制代码
describe('only suite',()=>{
    it.only('only case1',()=>{
        cy.log('case1');
    })

    it.only('only case2',()=>{
        cy.log('case2');
    })

    it('case3',()=>{
        cy.log('case3');
    })
})
相关推荐
程序员三藏9 小时前
Jmeter接口测试与压力测试
自动化测试·软件测试·python·测试工具·jmeter·接口测试·压力测试
测试老哥13 小时前
Postman环境变量设置全攻略
自动化测试·软件测试·python·测试工具·职场和发展·接口测试·postman
程序员小远21 小时前
软件测试之压力测试详解
自动化测试·软件测试·python·测试工具·职场和发展·测试用例·压力测试
程序员杰哥3 天前
UI自动化测试实战:从入门到精通
自动化测试·软件测试·python·selenium·测试工具·ui·职场和发展
测试19983 天前
Jmeter是如何实现接口关联的?
自动化测试·软件测试·python·测试工具·jmeter·职场和发展·接口测试
西欧伯爵3 天前
Playwright自动化实战一
自动化测试·自动化·playwright
测试老哥4 天前
测试用例之正交试验法、功能图法
自动化测试·软件测试·python·功能测试·测试工具·职场和发展·测试用例
程序员三藏5 天前
银行测试:第三方支付平台业务流,功能/性能/安全测试方法
自动化测试·软件测试·python·功能测试·测试工具·职场和发展·安全性测试