zoukankan      html  css  js  c++  java
  • pytest框架_allure报告

    EXcelxmind....
    
    自己写用例 - 自己去执行 - 自己去写测试报告
    实际结果和预期结果的比对:手工比对
    
    
    测试框架:
    unittest -
    pytest -
    nose -
    behave - BDD
    
    pytest:
    
    编写测试用例 - 收集测试用例 - 执行测试用例 - 生成测试报告
    
    
    安装:
    1、pip install pytest==6.2.1
    
    
    编写测试用例:
       用例名称、用例步骤、预期结果 、实际结果 、前置后置
       1、用例名称:要以test_开头
       2、断言:(实际和预期的比对) assert 表达式(True/False)
               AssertionError
          用例失败:1、出现了AssertionError   2、用例抛其它异常了。
       用例呈现的2种形式:
          1、.py下的函数,函数名以test_开头
          2、.py下类(没有__init__方法)里面的方法,方法名以test_开头
    
    自动收集测试用例:
        1、收集用例的目录:以rootdir作为根目录。从rootdir目录下开始搜索用例。
        2、目录下的文件过滤:文件名以test_开头的py文件,或者文件名以_test结尾的py文件。
        3、文件下的用例过滤:.py下的函数,函数名以test_开头/.py下类(Test开头)里面的方法,方法名以test_开头
    
        执行顺序:
           先找到哪个文件,就先执行哪个文件里的用例。
           文件顺序:ASCII
           文件里有多个用例,用例按什么顺序执行?
           文件内部:自上而下,按照代码先后顺序执行。
    
    
    pytest报告:
      html报告 - html插件
            1、pip install pytest-html
            2、pytest命令加入参数:--html=报告路径(相对于rootdir)
    
      allure报告 - allure插件
      allure: 工具。-- 花式呈现测试报告。解析测试结果文件然后生成多维度数据展示的报告。
      博客地址:https://www.cnblogs.com/Simple-Small/p/11512337.html
    
      1、要生成allure工具可以解析的测试结果文件
         pytest生成
         但是需要插件:
           pip install allure-pytest
    
      2、再用allure工具,将测试结果文件生成报告。
         allure文档地址:https://docs.qameta.io/allure/
            1) 安装allure命令行工具
               下载地址:https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline/
               下载zip文件,解压任意目录
               将allure解压目录配置环境变量:D:allure-2.12.1in
            2) 用allure命令去生成报告:
                ps: 测试结果文件的路径不能出错哦。
                命令:allure serve allure-report-files
                测试结果文件的路径 cd /Users/zhangping/PycharmProjects/py_37/Py_Pytest/day17
    
      3、在pytest执行用例的命令当中,添加:
         --alluredir=路径(相对于rootdir)
    
    
    mark分类 - 对收集到的所有用例,做一定滤
    前置后置 - fixture
    预习文章:https://www.cnblogs.com/Simple-Small/p/13878172.html
  • 相关阅读:
    动态传参
    函数的介绍
    文件的操作
    send email with formatted table
    minimize and close window with customed winform
    python algorithm
    something important about docker
    book list
    which language is suitable for what to do
    Find Duplicate Items in list fast
  • 原文地址:https://www.cnblogs.com/zhang-ping1205/p/14448423.html
Copyright © 2011-2022 走看看