当前位置:网站首页>Pytest interface automation testing framework | multi process running case
Pytest interface automation testing framework | multi process running case
2022-07-24 00:14:00 【COCOgsta】
Video source :B standing 《 Risking your life to upload !pytest Interface automation test framework ( From basic theory to project practice and secondary development ) Teaching video 【 software test 】》
Organize the teacher's course content and test notes while studying , And share it with you , Infringement is deleted , Thank you for your support !
Attach summary sticker :pytest Interface automation test framework | Summary _COCOgsta The blog of -CSDN Blog
install pytest-xdist
pip install pytest-xdist
Operation mode :
pytest -n NUMCPUS
import pytest
def test_case01():
assert 1==1
def test_case02():
assert 1 == 1
def test_case03():
assert 1 == 3
def test_case04():
assert 1 == 4
def test_case05():
assert 1 == 5
def test_case06():
assert 1 == 1
if __name__ == '__main__':
# Send tests to multiple CPU
# pytest.main(["-n", "2", "test_many.py"])
# Use the CPU As many processes as the kernel
pytest.main(["-n", "auto", "test_many.py"])It also takes effect through command line execution
PS D:\SynologyDrive\CodeLearning\WIN\pytest\base_used> pytest .\test_fail2.py --maxfail 2
======================================================================================================== test session starts ========================================================================================================
platform win32 -- Python 3.6.6, pytest-7.0.1, pluggy-1.0.0
rootdir: D:\SynologyDrive\CodeLearning\WIN\pytest\base_used
plugins: allure-pytest-2.9.45, forked-1.4.0, html-3.1.1, metadata-1.11.0, ordering-0.6, rerunfailures-10.2, xdist-2.5.0
collected 3 items
test_fail2.py FF
============================================================================================================= FAILURES ==============================================================================================================
____________________________________________________________________________________________________________ test_fail01 ____________________________________________________________________________________________________________
def test_fail01():
print(" The first failure ")
> assert 1==2
E assert 1 == 2
test_fail2.py:6: AssertionError
------------------------------------------------------------------------------------------------------- Captured stdout call --------------------------------------------------------------------------------------------------------
The first failure
____________________________________________________________________________________________________________ test_fail02 ____________________________________________________________________________________________________________
def test_fail02():
print(" The second failure ")
> assert 1 == 2
E assert 1 == 2
test_fail2.py:11: AssertionError
------------------------------------------------------------------------------------------------------- Captured stdout call --------------------------------------------------------------------------------------------------------
The second failure
====================================================================================================== short test summary info ======================================================================================================
FAILED test_fail2.py::test_fail01 - assert 1 == 2
FAILED test_fail2.py::test_fail02 - assert 1 == 2
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 2 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
========================================================================================================= 2 failed in 0.09s =========================================================================================================
PS D:\SynologyDrive\CodeLearning\WIN\pytest\base_used>
PS D:\SynologyDrive\CodeLearning\WIN\pytest\base_used> pip install pytest-xdist
Requirement already satisfied: pytest-xdist in c:\users\guoliang\appdata\local\programs\python\python36\lib\site-packages (2.5.0)
Requirement already satisfied: pytest>=6.2.0 in c:\users\guoliang\appdata\local\programs\python\python36\lib\site-packages (from pytest-xdist) (7.0.1)
Requirement already satisfied: execnet>=1.1 in c:\users\guoliang\appdata\local\programs\python\python36\lib\site-packages (from pytest-xdist) (1.9.0)
Requirement already satisfied: pytest-forked in c:\users\guoliang\appdata\local\programs\python\python36\lib\site-packages (from pytest-xdist) (1.4.0)
Requirement already satisfied: colorama; sys_platform == "win32" in c:\users\guoliang\appdata\local\programs\python\python36\lib\site-packages (from pytest>=6.2.0->pytest-xdist) (0.4.5)
Requirement already satisfied: importlib-metadata>=0.12; python_version < "3.8" in c:\users\guoliang\appdata\local\programs\python\python36\lib\site-packages (from pytest>=6.2.0->pytest-xdist) (4.8.3)
Requirement already satisfied: attrs>=19.2.0 in c:\users\guoliang\appdata\local\programs\python\python36\lib\site-packages (from pytest>=6.2.0->pytest-xdist) (21.4.0)
Requirement already satisfied: atomicwrites>=1.0; sys_platform == "win32" in c:\users\guoliang\appdata\local\programs\python\python36\lib\site-packages (from pytest>=6.2.0->pytest-xdist) (1.4.1)
Requirement already satisfied: tomli>=1.0.0 in c:\users\guoliang\appdata\local\programs\python\python36\lib\site-packages (from pytest>=6.2.0->pytest-xdist) (1.2.3)
Requirement already satisfied: pluggy<2.0,>=0.12 in c:\users\guoliang\appdata\local\programs\python\python36\lib\site-packages (from pytest>=6.2.0->pytest-xdist) (1.0.0)
Requirement already satisfied: py>=1.8.2 in c:\users\guoliang\appdata\local\programs\python\python36\lib\site-packages (from pytest>=6.2.0->pytest-xdist) (1.11.0)
Requirement already satisfied: iniconfig in c:\users\guoliang\appdata\local\programs\python\python36\lib\site-packages (from pytest>=6.2.0->pytest-xdist) (1.1.1)
Requirement already satisfied: packaging in c:\users\guoliang\appdata\local\programs\python\python36\lib\site-packages (from pytest>=6.2.0->pytest-xdist) (21.3)
Requirement already satisfied: zipp>=0.5 in c:\users\guoliang\appdata\local\programs\python\python36\lib\site-packages (from importlib-metadata>=0.12; python_version < "3.8"->pytest>=6.2.0->pytest-xdist) (3.6.0)
Requirement already satisfied: typing-extensions>=3.6.4; python_version < "3.8" in c:\users\guoliang\appdata\local\programs\python\python36\lib\site-packages (from importlib-metadata>=0.12; python_version < "3.8"->pytest>=6.2.0->p
ytest-xdist) (4.1.1)
Requirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in c:\users\guoliang\appdata\local\programs\python\python36\lib\site-packages (from packaging->pytest>=6.2.0->pytest-xdist) (3.0.7)
You are using pip version 10.0.1, however version 21.3.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
PS D:\SynologyDrive\CodeLearning\WIN\pytest\base_used> pytest .\test_fail2.py -n=2
======================================================================================================== test session starts ========================================================================================================
platform win32 -- Python 3.6.6, pytest-7.0.1, pluggy-1.0.0
rootdir: D:\SynologyDrive\CodeLearning\WIN\pytest\base_used
plugins: allure-pytest-2.9.45, forked-1.4.0, html-3.1.1, metadata-1.11.0, ordering-0.6, rerunfailures-10.2, xdist-2.5.0
gw0 [3] / gw1 [3]
FF. [100%]
============================================================================================================= FAILURES ==============================================================================================================
____________________________________________________________________________________________________________ test_fail01 ____________________________________________________________________________________________________________
[gw0] win32 -- Python 3.6.6 c:\users\guoliang\appdata\local\programs\python\python36\python.exe
def test_fail01():
print(" The first failure ")
> assert 1==2
E assert 1 == 2
test_fail2.py:6: AssertionError
------------------------------------------------------------------------------------------------------- Captured stdout call --------------------------------------------------------------------------------------------------------
The first failure
____________________________________________________________________________________________________________ test_fail02 ____________________________________________________________________________________________________________
[gw1] win32 -- Python 3.6.6 c:\users\guoliang\appdata\local\programs\python\python36\python.exe
def test_fail02():
print(" The second failure ")
> assert 1 == 2
E assert 1 == 2
test_fail2.py:11: AssertionError
------------------------------------------------------------------------------------------------------- Captured stdout call --------------------------------------------------------------------------------------------------------
The second failure
====================================================================================================== short test summary info ======================================================================================================
FAILED test_fail2.py::test_fail01 - assert 1 == 2
FAILED test_fail2.py::test_fail02 - assert 1 == 2
==================================================================================================== 2 failed, 1 passed in 0.84s ====================================================================================================
PS D:\SynologyDrive\CodeLearning\WIN\pytest\base_used> pytest .\test_many.py -n=2
======================================================================================================== test session starts ========================================================================================================
platform win32 -- Python 3.6.6, pytest-7.0.1, pluggy-1.0.0
rootdir: D:\SynologyDrive\CodeLearning\WIN\pytest\base_used
plugins: allure-pytest-2.9.45, forked-1.4.0, html-3.1.1, metadata-1.11.0, ordering-0.6, rerunfailures-10.2, xdist-2.5.0
gw0 [6] / gw1 [6]
..FFF. [100%]
============================================================================================================= FAILURES ==============================================================================================================
____________________________________________________________________________________________________________ test_case03 ____________________________________________________________________________________________________________
[gw0] win32 -- Python 3.6.6 c:\users\guoliang\appdata\local\programs\python\python36\python.exe
def test_case03():
> assert 1 == 3
E assert 1 == 3
test_many.py:12: AssertionError
____________________________________________________________________________________________________________ test_case04 ____________________________________________________________________________________________________________
[gw1] win32 -- Python 3.6.6 c:\users\guoliang\appdata\local\programs\python\python36\python.exe
def test_case04():
> assert 1 == 4
E assert 1 == 4
test_many.py:16: AssertionError
____________________________________________________________________________________________________________ test_case05 ____________________________________________________________________________________________________________
[gw0] win32 -- Python 3.6.6 c:\users\guoliang\appdata\local\programs\python\python36\python.exe
def test_case05():
> assert 1 == 5
E assert 1 == 5
test_many.py:20: AssertionError
====================================================================================================== short test summary info ======================================================================================================
FAILED test_many.py::test_case03 - assert 1 == 3
FAILED test_many.py::test_case04 - assert 1 == 4
FAILED test_many.py::test_case05 - assert 1 == 5
==================================================================================================== 3 failed, 3 passed in 0.83s ====================================================================================================
PS D:\SynologyDrive\CodeLearning\WIN\pytest\base_used>
边栏推荐
猜你喜欢
随机推荐
Redis cluster construction (cluster cluster mode, fragment cluster)
Windows软件:如何安装Mysql5.7并配置环境变量
Pushgateway+prometheus+grafana build Flink real-time monitoring
[opencv] - when the parameter type of cv.threshold() function is a number, what does it mean
STL case - judges' scoring
day2
盘点为下个牛市做准备的10个新Layer1
[wechat applet] design and interactive implementation of auction product details page (including countdown and real-time update of bids)
太空射击第08课: 改进的碰撞
自己喜欢投资
数据驱动之Excel读写
[wechat Payment]
July 23, 2022 - mapper file description
Esp8266 - at command + network transparent transmission
【HCIP】MGRE环境下OSPF实验,含多进程双向重发布及OSPF特殊区域
尝试新的方法
Realize the function of uploading and downloading files and directories similar to RZ and SZ on the native terminal
QT create a background mask, pop up the child window, and the background of the parent window turns black and dark
[details] radio label, change the default selected background color
Sentinel链路方式流控失效解决









![[Android kotlin] property, getter and setter](/img/f7/a3b79e3f7c4396a240eb5749c450d3.png)