博客
关于我
pytest自动化测试-Git中的测试用例运行
阅读量:799 次
发布时间:2023-03-05

本文共 617 字,大约阅读时间需要 2 分钟。

前言

在自动化测试项目中,我们每天都会提交测试用例到Git仓库。随着用例数量的增加,为了确保仓库代码的整洁性,我们希望能够只运行新增但尚未提交到Git仓库的用例。这时,pytest-picked插件就能派上用场。

安装方法

通过命令行安装pytest-picked插件:

pip install pytest-picked

参数说明

插件提供以下参数:

- `picked`:指定要运行的测试文件类型,默认为`[only, first]`。 - `mode`:指定运行模式,选项为`unstaged`和`branch`,默认为`unstaged`。

使用示例

以下是不同参数组合的示例:

pytest --picked  pytest --picked=first  pytest --picked --mode=branch  pytest --picked --mode=unstaged

文件状态解释

在Git中,文件可以有以下状态:

- **Untracked**:未被版本控制系统跟踪的文件,这些文件不会出现在当前分支的`git status`中。 - **Staged**:已暂存但尚未提交的文件,这些文件会被包含在下一次提交中。

运行测试

默认情况下,`pytest --picked`会运行所有未提交的文件和尚未暂存的文件。

如果需要只运行当前分支上已暂存但尚未提交的文件,可以使用`--mode=branch`参数。

转载地址:http://inafk.baihongyu.com/

你可能感兴趣的文章
PrintStream概述
查看>>
Prismix:Prisma 架构混合器,为复杂项目而生
查看>>
Private Destructor
查看>>
private和protected能同时修饰成员变量吗_天天用注解你了解注解是怎么实现的吗?...
查看>>
privoxy Invalid header received from client.
查看>>
Privoxy代码下载
查看>>
Progress Kemp LoadMaster 远程命令执行漏洞复现(CVE-2024-1212)
查看>>
Project configuration is not up-to-date with pom.xml. Run Maven->Update Project
查看>>
Project Euler 15 Lattice paths
查看>>
Project Euler 48 Self powers( 大数求余 )
查看>>
Project Euler Problem 12: Highly divisible triangular number
查看>>
ProjectEuler 2
查看>>
projection介绍及EPSG:4326和EPSG:3857的投射转换
查看>>
project打开文件时,显示无法识别此文件格式?
查看>>
Prometheus + Grafana on Kubernetes部署
查看>>
prometheus + grafana进行服务器资源监控
查看>>
Prometheus Grafana 展示平台
查看>>
Prometheus pushgateway使用详解
查看>>
Prometheus 云原生 - Prometheus 数据模型、Metrics 指标类型、Exporter 相关
查看>>
Prometheus 云原生 - 基于 file_sd、http_sd 实现 Service Discovery
查看>>