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的一些其他的运行用法的更多相关文章

  1. pytest之收集用例规则与运行指定用例

    前言 上篇文章相信大家已经了解了pytest在cmd下结合各种命令行参数如何运行测试用例,并输出我们想要看到的信息.那么今天会讲解一下pytest是如何收集我们写好的用例?我们又有哪些方式来运行单个用 ...

  2. pytest四:fixture_yield 实现 teardown

    既然有 setup 那就有 teardown,fixture 里面的 teardown 用 yield 来唤醒 teardown的执行 在所有用例执行完后执行:yield import pytest ...

  3. pytest系列(四)- pytest+allure+jenkins - 持续集成平台生成allure报告

    pytest是什么 pytest是python的一款测试框架,拥有unittest的功能并比它更丰富. allure是什么 有非常多的优秀的测试框架,但却是有非常少优秀的报告工具可以展示非常清楚的用例 ...

  4. pytest的断言、跳过、运行的按需要处理

    def test_one(): assert 1==1 assert 1!=2 assert {'name':'linda','age':19}=={'name':'linda','age':190} ...

  5. 二、为什么要选用pytest以及 pytest与unittest比较

    为什么要选择pytest,我看中的如下: 写case,不需要像unittest那样,创建测试类,继承unittest.TestCase pytest中的fixture(类似于setUp.tearDow ...

  6. pytest配置文件pytest.ini

    说明: pytest.ini是pytest的全局配置文件,一般放在项目的根目录下 是一个固定的文件-pytest.ini 可以改变pytest的运行方式,设置配置信息,读取后按照配置的内容去运行 py ...

  7. 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 ...

  8. pytest 用 @pytest.mark.usefixtures("fixtureName")装饰类,可以让执行每个case前,都执行一遍指定的fixture

    conftest.py import pytest import uuid @pytest.fixture() def declass(): print("declass:"+st ...

  9. Java进阶(四)Java反射TypeToken解决泛型运行时类型擦除问题

    在开发时,遇到了下面这条语句,不懂,然习之. private List<MyZhuiHaoDetailModel> listLottery = new ArrayList<MyZhu ...

随机推荐

  1. 28-关键字:static

    static:静态的 1.可以用来修饰的结构:主要用来修饰类的内部结构 >属性.方法.代码块.内部类 2.static修饰属性:静态变量(或类变量) 2.1 属性,是否使用static修饰,又分 ...

  2. pageHelper使用时的注意点

    1 在pom.xml中导入相关的依赖(注意版本问题,报错十有八九是因为版本问题) <dependency> <groupId>com.github.pagehelper< ...

  3. 操作属性、操作样式 - DOM编程

    1. 操作属性 1.1 HTML 属性与 DOM 属性的对应 <div> <label for="username">User Name: </lab ...

  4. JavaScript的continue、break和return的区别

    1. continue.break和return的区别 循环遍历. for(let i = 0; i < 5; i++){ console.log(i); // 0 1 2 3 4 } 使用co ...

  5. 【lhyaaa】最近公共祖先LCA——倍增!!!

    高级的算法——倍增!!! 根据LCA的定义,我们可以知道假如有两个节点x和y,则LCA(x,y)是 x 到根的路 径与 y 到根的路径的交汇点,同时也是 x 和 y 之间所有路径中深度最小的节 点,所 ...

  6. java_数组的定义与操作

    数组定义和访问 数组概念 数组概念: 数组就是存储多个数据的容器,数组的长度固定,多个数据的数据类型要一致. 数组的定义 方式一 数组存储的数据类型[] 数组名字 = new 数组存储的数据类型[长度 ...

  7. Linux中C++提示‘close’ was not declared

    C++socket编程时关闭socket和epoll时出现‘close’ was not declared,是程序头文件缺失导致的.缺失头文件#include <unistd.h>

  8. Goland 生成可执行文件

    Goland通过调用go build 生成可执行文件. 默认Goland是可以执行程序,但你找不到可执行文件. 你需要自定义配置文件. 创建go build配置文件 Run kind 选Directo ...

  9. RPC 框架 Dubbo 从理解到使用(一)

    技术架构演变 单一应用架构 通俗地讲,"单体应用(monolith application)"就是将应用程序的所有功能都打包成一个独立的单元.当网站流量很小时,只需一个应用,将所有 ...

  10. 弱校验之@NotNull@NotEmpty@NotBlank

    @NotNull 适用于非空判断 The annotated element must not be {@code null}. CharSequence, Collection, Map 和 Arr ...