首页 > 其他分享 >Selenium64-pytest.ini

Selenium64-pytest.ini

时间:2023-01-07 10:03:09浏览次数:28  
标签:-% log Selenium64 report pytest ini test 日志

配置文件pytest.ini

  • pytest.ini是什么?
  • pytest.ini是pytest的主配置文件,可以改变pytest的默认行为,有很多可配置的选项。
  • 在执行文件根目录配置pytest.ini文件。
  • 日志的作用:
  • 我们可以借助日志帮忙调试程序;
  • 借助日志做监控报警。
  • pytest 支持
  • 自动捕获WARNING级别或更高级别的日志消息,并以与捕获的stdout和stderr相同的方式将它们显示在每个失败的测试输出信息中
  • pytest先从pytest.ini中读取log_cli配置的,默认是关闭的

新建report和logs目录

  • 新建目录
  • report
  • logs

配置日志

  • 通过将log_cli配置设置为true或1,pytest 将输出日志记录到控制台。
    [pytest]
    log_cli = 1
    log_cli_level = INFO
    log_cli_date_format = %Y-%m-%d-%H-%M-%S
    log_cli_format = %(asctime)s - %(filename)s[line %(lineno)d] - %(funcName)s - %(levelname)s - %(message)s
配置日志执行目录和文件名称
  • 将整个测试产生的日志记录一个文件中,此日志文件以写入模式打开,每次运行测试都会覆盖上一次测试日志
    log_file = ../logs/test.log
    log_file_level = INFO
    log_file_date_format = %Y-%m-%d-%H-%M-%S
    log_file_format = %(asctime)s - %(filename)s[line %(lineno)d] - %(funcName)s - %(levelname)s - %(message)s
配置执行目录、文件名称规则
  • testpaths:指示pytest访问路径。
    • testpaths是一系列相对于根目录的路径,用于限定测试用例的搜索范围。
    • 只有在pytest未指定文件目录参数或测试用例标识符时,该选项才有作用
  • 示例:
    • testpaths = ./testcasecode/
    • python_files = test_*_v7.py
addopts更改默认命令行选项
  • addopts:更改默认命令行选项。
    • pytest用命令行运行时,有时候需要经常要用到某些参数,又不想重复输入,这时可以使用pytest.ini文件里的addopts设置
  • 示例:
    • addopts = --reruns 2 --reruns-delay 3 --html=./report/report.html --self-contained-html
命令行运行pytest
  • 命令行切换到aiseproject2目录,输入pytest命令运行
  • D:\PycharmProjects\aiseProject2>pytest
  • ============== test session starts ==========
  • platform win32 -- Python 3.9.5, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
  • sensitiveurl: .*
  • rootdir: D:\PycharmProjects\aiseProject2, configfile: pytest.ini, testpaths: ./testcasecode/
  • collected 10 items
  • testcasecode/test_后台_双创_基础设置_赛区管理_添加赛区_case_v7.py::TestAddDivision::test_add_division[A-……f] PASSED [ 10%]
  • testcasecode/test_后台_双创_基础设置_赛区管理_添加赛区_case_v7.py::TestAddDivision::test_add_division[-……f] PASSED [ 20%]
  • ……
  • testcasecode/test_后台_双创_基础设置_赛区管理_添加赛区_case_v7.py::TestAddDivision::test_add_division[-……f] PASSED [ 100%]
  • -------------- generated html file: file://D:\PycharmProjects\aiseProject2\report\report.html -----
  • ========= 10 passed in 636.55s (0:10:36) ================
  • Selenium64-pytest.ini_基础设置


查看报告文件
  • report:report.html
  • Selenium64-pytest.ini_html_02


报告详情

Selenium64-pytest.ini_html_03



作者:暄总-tester











标签:-%,log,Selenium64,report,pytest,ini,test,日志
From: https://blog.51cto.com/u_14911999/5995391

相关文章

  • BeanDefinition基本定义
    BeanDefinition定义了Bean的基本元信息、生命周期方法等。描述了SpringBean的基本信息。其初始化方法主要有以下两种方式:本文案例也是基于SpringFramework5.2.2.RELEAS......
  • 关于报错Caused by: java.lang.NoSuchMethodException: com.zuo.dao.StudentMapper.<i
    源代码报错解决方法注意在ResultMap(结果集映射)中,给type起的别名这里应该是实体类的全限定名为不是Mapper的!!! ......
  • Docker安装MinIO
    文章目录​​前言​​​​安装​​​​访问​​前言MinIO是一个基于ApacheLicensev2.0开源协议的对象存储服务。它兼容亚马逊S3云存储服务接口,非常适合于存储大容量非结......
  • minio+avc+rclone 集成试用
    avc可以试用类似git的模式管理数据支持版本以及变动,tag,以下是一个简单的集成试用环境准备安装avc+rclone工具可以通过官方下载使用docker-compose v......
  • 解决Consider defining a bean of type ‘*Mapper‘ in your configuration.
    pom.xml<dependency><groupId>org.mybatis.spring.boot</groupId><artifactId>mybatis-spring-boot-starter</artifactId><version>2.0.1</version></depen......
  • Python接口自动化系列- 读取 ini 配置文件05
    一、ini文件的组成一个ini文件是由多个section组成,每个section中以key=vlaue形式存储数据; 二、python读取ini文件数据1、导包importconfigparserconfig=configp......
  • nodeAffinity
    查看路径[root@k8smaster4ns]#kubectlexplainpod.spec.affinityAffinity类别nodeAffinitypodAffinitypodAntiAffinity编写Yaml文件[root@k8smaster4ns]#catpod-nodeA......
  • pytest测试使用
    固件:pytest.fixture()定义固件pytest会在执行测试函数之前(或之后)加载运行它们,最常见的可能就是数据库的初始连接和最后关闭操作标记:pytest.mark.***pytest会在执行......
  • Spring bean注入问题:NoUniqueBeanDefinitionException解决方案归纳
    引言   spring实现的bean自动注入在项目开发中是一个经常使用到的功能,但自动装配两个或多个bean时,会抛出NoUniqueBeanDefinitionException:Noqualifyingbeanoftyp......
  • Unity小地图Minimap制作全面功能介绍篇
    本系列文章将讲述如何制作小地图。功能如下:  小地图的局部放大地图,缩小功能。小地图展开成为大地图,以及与大地图的互相切换  大地图的人物图标跟随角色旋转和移动 ......