.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');
    })
})
相关推荐
程序员龙叔6 天前
编写高质量 Skill 系列 -- 如何设计需求分析与用例生成的 SKILL
自动化测试·软件测试·python·软件测试工程师·接口测试·性能测试·skill·ai测试
goldenrolan6 天前
A公司物料替代测试系统 v1.7:从需求到 exe/apk 的 AI 辅助全链路实践
android·自动化测试·软件测试·python·ai
程序员小远6 天前
自动化测试基础知识总结
自动化测试·软件测试·python·selenium·测试工具·职场和发展·测试用例
程序员三藏7 天前
Web自动化测试详解
自动化测试·软件测试·python·selenium·测试工具·职场和发展·测试用例
程序员龙叔7 天前
从 0 开始学习 AI 测试 - 从接口测试来教你如何用 AI 来生成自动化测试代码
自动化测试·软件测试·python·软件测试工程师·测试工具·性能测试·ai测试
纳米软件9 天前
CSDN:5G_6G毫米波射频芯片测试,如何解决OTA测试中的“测不准”与“效率低”?
自动化测试·5g·ate测试·ate测试系统·电子测试测量·电子测试工具
大貔貅喝啤酒10 天前
Python Requests库教程
自动化测试·python·requests库
测试开发技术10 天前
AI 测试赋能全流程实战 | Agent Skill + AI 赋能「需求分析」
自动化测试·人工智能·自动化·需求分析·ai编程·ai测试