【pytest】(四) pytest的一些其他的运行用法
1. 可以设置当失败N个后停止测试
pytest -x 是当第一个失败产生后,停止
pytest --maxfail=2, 这里就是当失败2个用例后,停止测试
2.pytest 在命令行模式下支持多种方式运行和选择运行
- pytest test_mod.py 运行这个文件(模块)
- pytest testing/ 运行指定目录下的测试文件
3. 指定运行文件下具体类下的具体方法,用:: 分隔 文件、类、 方法
pytest test_mod.py::TestClass::test_method
4.pytest中同样提供了main() 来函数来执行测试用例
import pytest
def test_main():
assert 5 != 5
if __name__ == '__main__':
pytest.main()
sublime, ctrl + b 即可运行
5.在main()下运行指定目录文件,也可以加参数,比如
import pytest
def test_main():
assert 5 != 5
if __name__ == '__main__':
pytest.main("d:/pyse/pytest/") # 指定测试目录
【pytest】(四) pytest的一些其他的运行用法的更多相关文章
- pytest之收集用例规则与运行指定用例
前言 上篇文章相信大家已经了解了pytest在cmd下结合各种命令行参数如何运行测试用例,并输出我们想要看到的信息.那么今天会讲解一下pytest是如何收集我们写好的用例?我们又有哪些方式来运行单个用 ...
- pytest四:fixture_yield 实现 teardown
既然有 setup 那就有 teardown,fixture 里面的 teardown 用 yield 来唤醒 teardown的执行 在所有用例执行完后执行:yield import pytest ...
- pytest系列(四)- pytest+allure+jenkins - 持续集成平台生成allure报告
pytest是什么 pytest是python的一款测试框架,拥有unittest的功能并比它更丰富. allure是什么 有非常多的优秀的测试框架,但却是有非常少优秀的报告工具可以展示非常清楚的用例 ...
- pytest的断言、跳过、运行的按需要处理
def test_one(): assert 1==1 assert 1!=2 assert {'name':'linda','age':19}=={'name':'linda','age':190} ...
- 二、为什么要选用pytest以及 pytest与unittest比较
为什么要选择pytest,我看中的如下: 写case,不需要像unittest那样,创建测试类,继承unittest.TestCase pytest中的fixture(类似于setUp.tearDow ...
- pytest配置文件pytest.ini
说明: pytest.ini是pytest的全局配置文件,一般放在项目的根目录下 是一个固定的文件-pytest.ini 可以改变pytest的运行方式,设置配置信息,读取后按照配置的内容去运行 py ...
- pytest 用 @pytest.mark.usefixtures("fixtureName")或@pytest.fixture(scope="function", autouse=True)装饰,实现类似setup和TearDown的功能
conftest.py import pytest @pytest.fixture(scope="class") def class_auto(): print("&qu ...
- pytest 用 @pytest.mark.usefixtures("fixtureName")装饰类,可以让执行每个case前,都执行一遍指定的fixture
conftest.py import pytest import uuid @pytest.fixture() def declass(): print("declass:"+st ...
- Java进阶(四)Java反射TypeToken解决泛型运行时类型擦除问题
在开发时,遇到了下面这条语句,不懂,然习之. private List<MyZhuiHaoDetailModel> listLottery = new ArrayList<MyZhu ...
随机推荐
- “随手记”开发记录day20
练习软件的展示,尽量将软件全方面的展示给大众,希望不要像上次一样有许多遗漏的地方,让其他团队以为我们的软件没有完善的功能.
- Springboot中如何自定义注解以及使用2例
不说废话,直接进入正题: java自定义注解主要有3步:1.编写@interface接口2.编写@interface对应的处理方法进行处理3.调用处理方法 示例一:判断奇偶:比如有一个字段no要判断奇 ...
- 初识TypeScript:查找指定路径下的文件按类型生成json
如果开发过node.js的话应该对js(javascript)非常熟悉,TypeScript(以下简称ts)是js的超集. 下面是ts的官网: https://www.tslang.cn/ 1.环境配 ...
- AAPT: error: resource android:attr/dialogCornerRadius not found. Android resource linking failed
打开android\app\build.gradle 修改 compileSdkVersion 和 targetSdkVersion
- 2020-04-10:有一个 API 服务,后端只使用了数据库来持久化数据,平时在 API 网关上监控到响应时间平均值大约为10ms,现在突然上涨到 5s,而且一直居高不下。请简单描述一下你排查这个问题的思路。
福哥答案2020-04-11: 1 排查api服务 是否是有大量请求 2 查看mysql的系统情况 cpu 磁盘io 连接数 还是要先定位问题出现在哪个环节
- 初始化vtable
在InstanceKlass::link_class_impl()方法中完成方法连接后会继续初始化vtable与itable,之前已经介绍过vtable与itable,并且在类解析过程中已经完成了大小 ...
- Quartz:基本用法总结
OpenSymphony所提供的Quartz是任务调度领域享誉盛名的开源框架.Spring提供了集成Quartz的功能,可以让开发人员以更面向Spring的方式创建基于Quartz的任务调度应用.任务 ...
- 下载 golang.org/x 包出错不用代理的解决办法
原文链接:https://www.jianshu.com/p/6fe61053c8aa?utm_campaign=maleskine&utm_content=note&utm_medi ...
- ftp 搭建 centos 源
1. yum -y install vsftpd* 2. /etc/init.d/vsftpd restart 3. mount CentOS-7-aarch64-Everything-1810 ...
- markdown 绘图利器之granphviz
目录 概述 graphviz 脚本语法结构 图 方向,尺寸,间距 节点 shape 属性 多边形 record-based 的形状 用户定制 label 属性 基本用法 HTML用法 style 属性 ...