当前位置:网站首页>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 .
边栏推荐
- Serial port experiment - simple data sending and receiving
- Simulation volume leetcode [general] 1567 Length of the longest subarray whose product is a positive number
- STM32的时钟系统
- STM32 serial port register library function configuration method
- Full link voltage test of the e-commerce campaign Guide
- Skills that testers must know: Selenium's three waiting ways are interpreted clearly
- GoLand set goproxy
- 模拟卷Leetcode【普通】1705. 吃苹果的最大数目
- OpenGL 3D graphics rendering
- 2022-07-06 Unity核心9——3D动画
猜你喜欢
Goldbach conjecture C language
On December 8th, 2020, the memory of marketing MRC application suddenly increased, resulting in system oom
2020 year end summary
C language pointer (Part 2)
使用Typora编辑markdown上传CSDN时图片大小调整麻烦问题
Troublesome problem of image resizing when using typora to edit markdown to upload CSDN
2022-06-30 unity core 8 - model import
Systick滴答定时器
2022-07-06 Unity核心9——3D动画
How to pass the PMP Exam in a short time?
随机推荐
Recommended by Alibaba P8, the test coverage tool - Jacobo is very practical
MySQL主从延迟的解决方案
Analysis of Hessian serialization principle
Unity shader beginner's Essentials (I) -- basic lighting notes
串口实验——简单数据收发
模拟卷Leetcode【普通】1705. 吃苹果的最大数目
C语言指针(上篇)
硬核分享:硬件工程师常用工具包
RuntimeError: Calculated padded input size per channel: (1 x 1). Kernel size: (5 x 5). Kernel size c
STM32 clock system
JVM 垃圾回收 详细学习笔记(二)
Cmake command line use
LeetCode 715. Range module
H3C vxlan configuration
go mod module declares its path as: gtihub. com/xxx-xx but was required as:xx-xx
ChaosBlade:混沌工程简介(一)
Hard core sharing: a common toolkit for hardware engineers
2022-06-30 unity core 8 - model import
NVIC interrupt priority management
systemd