当前位置:网站首页>Confitest of fixture py
Confitest of fixture py
2022-07-07 09:09:00 【Song_ Lun】
pytest Framework conftest.py
pytest brief introduction
- pytest yes python A unit testing framework of , And python Self contained unittest The test framework is similar but better than unittest The framework is simpler to use , More efficient .
- Support simple unit testing and complex functional testing , Support parameterization
- Support use case skipping and assertion operations ; Generative html Report and allure The report ; Facilitate continuous integration of tools and jenkins Integrate ; Third party plug-ins can be used
fixture And conftest.py
Simulate a scenario : Such as the 3 Users log in to the system to do different operations
- user 1: Get user information after login
- You don't need to log in to get the landing page news
- user 3: Get the message list after logging in
fixture advantage : Flexible naming ; Data sharing can be realized ; Can achieve .py File cross domain
Let's take a look at the case
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2022/2/11 11:10 In the morning
# @Name : peilun
# @File : test_fixture1.py
# @Software: PyCharm
import pytest
@pytest.fixture()
def login():
print(" In front of - Enter account password to log in ")
def test_01(login):
print(" user 1: Get user information after login ")
def test_02():
print(" user 2: You don't need to log in to get the landing page news ")
def test_03(login):
print(" user 3: Get the message list after logging in ")
if __name__ == '__main__':
pytest.main(['-s', 'test_fixture1.py'])
The results are as follows :
= = == = == = == = == = == = == = == = == = =
If there are multiple use cases, you need to use conftest.py file ; File naming fixed !!!

Use conftest.py file Case The directory must contain __init__.py file ;conftest.py Files must be placed in the home directory .
边栏推荐
- OpenGL帧缓冲
- PMP experience learning and sharing process
- LED模拟与数字调光
- Panel display technology: LCD and OLED
- JVM garbage collection detailed learning notes (II)
- PMP examination experience sharing
- Simulation volume leetcode [general] 1567 Length of the longest subarray whose product is a positive number
- Systick滴答定时器
- Several methods of calculating the average value of two numbers
- LeetCode 715. Range 模块
猜你喜欢

How long does the PMP usually need to prepare for the exam in advance?

What is the use of PMP certificate?

硬核分享:硬件工程师常用工具包

Summary of PMP learning materials

串口实验——简单数据收发

Interview question: general layout and wiring principles of high-speed PCB

PMP examination experience sharing

STM32的时钟系统

JVM 内存结构 详细学习笔记(一)

C language for calculating the product of two matrices
随机推荐
2022-06-30 unity core 8 - model import
如何统计项目代码行数
go mod module declares its path as: gtihub. com/xxx-xx but was required as:xx-xx
Vagrant failed to mount directory mount: unknown filesystem type 'vboxsf'
C language pointer (Part 2)
Golang etcdv3 reports an error. The attribute in grpc does not exist
selenium自动化集成,八年测试经验软测工程师,一篇文章带你学懂
2021 year end summary
Port occupation troubleshooting
C language pointer (Part 1)
Expérience de port série - simple réception et réception de données
LeetCode 736. LISP syntax parsing
面试题:高速PCB一般布局、布线原则
C语言指针(中篇)
Several common database connection methods
MySQL主从延迟的解决方案
C语言指针(下篇)
C language pointer (exercises)
9c09730c0eea36d495c3ff6efe3708d8
ChaosBlade:混沌工程简介(一)