zoukankan      html  css  js  c++  java
  • pytest 编写规范

    一、pytest 编写规范

    1、介绍

    pytest是一个非常成熟的全功能的Python测试框架,主要特点有以下几点:

    • 1、简单灵活,容易上手,文档丰富;
    • 2、支持参数化,可以细粒度地控制要测试的测试用例;
    • 3、能够支持简单的单元测试和复杂的功能测试,还可以用来做selenium/appnium等自动化测试、接口自动化测试(pytest+requests);
    • 4、pytest具有很多第三方插件,并且可以自定义扩展,比较好用的如pytest-selenium(集成selenium)、pytest-html(完美html测试报告生成)、pytest-rerunfailures(失败case重复执行)、pytest-xdist(多CPU分发)等;

    2、安装: pip install pytest

    3、编写规范

    • 测试文件以test_开头(以_test结尾也可以)
    • 测试类以Test开头,并且不能带有 init 方法
    • 测试函数以test_开头

    二、pytest 运行

    1、pycharm 设置pytest 执行器

     

    2、pycharm 运行用例

    1、pytest 会自动识别

    1、以test_开头的方法为测试用例

    2、以Test 开头的类

    2、选择执行器

     可以在类\模块方法\类方法中执行

    3、pycharm 运行用例

  • 相关阅读:
    设计模式——策略模式
    LeetCode
    平凡世界里的万千思绪
    LeetCode
    LeetCode
    LeetCode
    LeetCode
    LeetCode
    LeetCode
    LeetCode
  • 原文地址:https://www.cnblogs.com/keenajiao/p/15784038.html
Copyright © 2011-2022 走看看