Подробную информацию можно найти в официальной документации.:https://docs.qameta.io/allure-report/;
Allure
является многоязычнымтестинструменты отчетности;Web
Отображение содержимого отчета в форме;Ключевой момент: расширение функций требует добавления декораторов в набор тестовых примеров.。(Подробнее читайте в последующих статьях)
pip3 install allure-pytest
C:\Users\Administrator>pip3 install allure-pytest
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Requirement already satisfied: allure-pytest in d:\python37\lib\site-packages (2.8.12)
Requirement already satisfied: six>=1.9.0 in d:\python37\lib\site-packages (from allure-pytest) (1.15.0)
Requirement already satisfied: allure-python-commons==2.8.12 in d:\python37\lib\site-packages (from allure-pytest) (2.8.12)
Requirement already satisfied: pytest>=4.5.0 in d:\python37\lib\site-packages (from allure-pytest) (6.2.4)
Requirement already satisfied: attrs>=16.0.0 in d:\python37\lib\site-packages (from allure-python-commons==2.8.12->allure-pytest) (20.3.0)
Requirement already satisfied: pluggy>=0.4.0 in d:\python37\lib\site-packages (from allure-python-commons==2.8.12->allure-pytest) (0.13.1)
Requirement already satisfied: importlib-metadata>=0.12 in d:\python37\lib\site-packages (from pytest>=4.5.0->allure-pytest) (2.1.1)
Requirement already satisfied: iniconfig in d:\python37\lib\site-packages (from pytest>=4.5.0->allure-pytest) (1.1.1)
Requirement already satisfied: py>=1.8.2 in d:\python37\lib\site-packages (from pytest>=4.5.0->allure-pytest) (1.10.0)
Requirement already satisfied: packaging in d:\python37\lib\site-packages (from pytest>=4.5.0->allure-pytest) (20.8)
Requirement already satisfied: colorama in d:\python37\lib\site-packages (from pytest>=4.5.0->allure-pytest) (0.4.4)
Requirement already satisfied: atomicwrites>=1.0 in d:\python37\lib\site-packages (from pytest>=4.5.0->allure-pytest) (1.4.0)
Requirement already satisfied: toml in d:\python37\lib\site-packages (from pytest>=4.5.0->allure-pytest) (0.10.2)
Requirement already satisfied: zipp>=0.5 in d:\python37\lib\site-packages (from importlib-metadata>=0.12->pytest>=4.5.0->allure-pytest) (1.2.0)
Requirement already satisfied: pyparsing>=2.0.2 in d:\python37\lib\site-packages (from packaging->pytest>=4.5.0->allure-pytest) (2.4.7)
pip3 install pytest
Windows
Операционная система,так что скачайzip
документ:
allure --version
C:\Users\Administrator>allure --version
2.13.2
# -*- coding:utf-8 -*-
# автор:Насекомые без границ
# Дата: 20 марта 2023 г.
# Имя файла: test_xxx.py
# Функция: пример
# Контактное лицо: VX (Ноама Нельсон)
# Блог: https://blog.csdn.net/NoamaNelson
import pytest
import time
class TestCase01():
def test_case_01(self):
time.sleep(1)
print("case01$$$$$$$$$$$$$$$$$$$$$")
def test_case_02(self):
time.sleep(1)
print("case02$$$$$$$$$$$$$$$$$$$$$")
def test_case_03(self):
time.sleep(1)
print("case03$$$$$$$$$$$$$$$$$$$$$")
def test_case_04(self):
time.sleep(1)
print("case04$$$$$$$$$$$$$$$$$$$$$")
def test_case_05(self):
time.sleep(1)
print("case05$$$$$$$$$$$$$$$$$$$$$")
def test_case_06(self):
time.sleep(1)
print("case06$$$$$$$$$$$$$$$$$$$$$")
class TestCase02():
def test_case_07(self):
time.sleep(1)
print("case07$$$$$$$$$$$$$$$$$$$$$")
def test_case_08(self):
time.sleep(1)
print("case08$$$$$$$$$$$$$$$$$$$$$")
def test_case_09(self):
time.sleep(1)
print("case08$$$$$$$$$$$$$$$$$$$$$")
if __name__ == '__main__':
pytest.main(["-s", "test_xxx.py"])
pytest -n auto --alluredir=xxx/xxx/xxx
запустить и просмотретьтестрезультат,в--alluredir
Путь, по которому хранится указанный отчет.,например:pytest -n auto --alluredir=allure
test_xxx.py
,Отчет сохраняется по пути текущего скрипта:pytest -n auto --alluredir=allure test_xxx.py
gw0 [9] / gw1 [9] / gw2 [9] / gw3 [9] / gw4 [9] / gw5 [9] / gw6 [9] / gw7 [9]
......... [100%]
============================================= 9 passed in 4.66s ==============================================
test_xxx.py
по тому же пути,создатьallure
издокументпапка:allure
команда для отображениятест Отчет:allure serve allure
(venv) F:\pytest_study\test_case\test_j>allure serve allure
Generating report to temp directory...
Report successfully generated to C:\Users\ADMINI~1\AppData\Local\Temp\743714976960418009\allure-report
Starting web server...
2023-03-20 11:16:28.270:INFO::main: Logging initialized @4392ms to org.eclipse.jetty.util.log.StdErrLog
Server started at <http://172.16.1.33:13959/>. Press <Ctrl+C> to exit
allure serve -p 8888 allure
Поле | иллюстрировать |
---|---|
| Обзор отчета |
| Категория: просмотрите, например, выполнение варианта использования. |
| Тестовый комплект,в соответствии с |
| Графики результатов теста, включая диаграмму распределения, приоритет, затраты времени и т. д. |
| Время выполнения варианта использования и т. д. |
| управляемое поведением, в соответствии с |
| в соответствии с |