Pytest+Allure создает отчеты о тестировании (простая версия со скриптом)

Pytest+Allure создает отчеты о тестировании (простая версия со скриптом)

скрипт питона:

#!/usr/bin/env python 
# encoding: utf-8 
"""
@author: 九九的金金子
@file: test_feature_story.py
@time: 2021/2/1 15:06
"""
import pytest
import allure


@allure.feature("搜索模块")
class TestSeach:
    def test_case1(self):
        print("case1")

    def test_case2(self):
        print("case2")


@allure.feature("登录模块")
class Testlogin:
    @allure.story("登录成功")
    @allure.title("登录成功")
    def test_login_success(self):
        with allure.step("步骤1:打开应用"):
            print("打开应用")

        with allure.step("步骤2:进入登录页面"):
            print("登录页面")

        with allure.step("步骤3:输入用户名和密码"):
            print("输入用户名和密码")
        print("这是登录成功:测试用例,登录成功")
        pass

    @allure.story("登录失败")
    @allure.title("登录失败")
    def test_login_success_a(self):
        print("这是登录失败:测试用例,登录成功")
        pass

    @allure.story("登录失败")
    @allure.title("登录失败")
    def test_login_success_b(self):
        print("这是登录失败:测试用例,登录成功")
        assert 1 == 2, 'error: b is bigger'

Этапы выполнения скрипта

Шаг 1: Запустите скрипт

pytest test_feature_story.py --alluredir ./result2 --clean-alluredir
# 执行用例脚本,结果输出到当前文件夹result2,如果存在,清除之前执行的结果。

Шаг 2: Выходной HTML-файл

allure generate ./result2 -o report2 --clean
# 将result2的内容转化成HTML格式,存在report2文件夹里,如果存在,先清除。

Шаг 3: Привяжите локальный IP-адрес, чтобы другие могли его открыть

allure open -h 100.119.xx.xx -p 8883 ./report2
# 将report2的结果,绑定在本机IP上,可以用IP地址访问

Allure генерирует отчеты об испытаниях

вставьте сюда описание изображения
вставьте сюда описание изображения
вставьте сюда описание изображения

Supongo que te gusta

Origin blog.csdn.net/daxiangaifashi/article/details/113570913
Recomendado
Clasificación