11.接口自动化测试-Allure报告(2)

1.如何同时执行多个测试文件

(1)新建bat文件
(2)写命令

cd ./testCase
pytest -s --alluredir ./report --clean-alluredir
allure serve ./report

2.Allure的不同层级应用

Allure层级
(1)第一层:项目层@allure.epic
(2)第二层:模块层@allure.feature
(3)第三层:接口层@allure.story
(4)第四层:用例层@allure.title
import pytest,allure,os
from libs.login import Login
from utils.handle_excel import get_excel_data
from utils.handle_path import report_path
from utils.handle_path import data_path
from common.baseApi import BaseAssert
#TestLogin继承BaseAssert

@allure.epic('项目名称-外卖项目')
@allure.feature('商铺模块')
# @pytest.mark.skip(reason='该模块暂时不要运行')
@pytest.mark.skipif(1==2,reason='条件满足就跳过')
class TestShop(BaseAssert):
    @pytest.mark.parametrize('title,inBody,expData', get_excel_data('商铺模块', 'Listshop','标题','请求参数','响应预期结果'))
    @allure.story('商铺列表接口')
    @allure.title("{title}")
    @pytest.mark.shop_list

    def test_shop_list(self,title,inBody,expData,shop_init):#shop_init初始化操作
        # 1.调用业务层封装的接口代码
        res=shop_init.query(inBody)
        # 2.断言实际返回结果与预期结果
        self.define_assert(res['code'],expData['code'])
    @pytest.mark.parametrize('title,inBody,expData', get_excel_data('商铺模块', 'Updateshop','标题','请求参数','响应预期结果'))
    @pytest.mark.shop_list
    @allure.story('商铺编辑')
    @allure.title("{title}")
    def test_shop_update(self,title,inBody,expData,shop_init):
    # 分步走
        with allure.step('1.店铺实例'): #店铺实例
            print('1.获取店铺实例')
        with allure.step('2.店铺列出接口获取shopid'): #店铺列出接口获取shopid
            shopID=shop_init.query({"page":1,"limit":2})['data']['records'][0]['id']
        with allure.step('3.图片上传接口'):# 图片上传接口
            resimage = shop_init.file_upload(data_path + '\\cat.jpg')
            imageInfo = resimage['data']['realFileName']
        with allure.step('4.调用编辑店铺接口'):
            res=shop_init.update(inBody,shopID,imageInfo)
            self.define_assert(res['code'],expData['code'])

if __name__ == '__main__':
    pytest.main([__file__,'-sv','-m','shop_list or shop_update','--alluredir',report_path,'--clean-alluredir'])
    os.system(f'allure serve {report_path}')

Allure报告:

在这里插入图片描述

相关推荐

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-04-21 06:48:02       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-04-21 06:48:02       100 阅读
  3. 在Django里面运行非项目文件

    2024-04-21 06:48:02       82 阅读
  4. Python语言-面向对象

    2024-04-21 06:48:02       91 阅读

热门阅读

  1. web自动化测试

    2024-04-21 06:48:02       36 阅读
  2. 【grpc】grpc进阶三,服务发现

    2024-04-21 06:48:02       33 阅读
  3. 【PHP快速上手(十三)】

    2024-04-21 06:48:02       36 阅读
  4. 计算机视觉入门

    2024-04-21 06:48:02       38 阅读
  5. Spring Boot集成atomikos快速入门Demo

    2024-04-21 06:48:02       29 阅读
  6. 数据分析(3)

    2024-04-21 06:48:02       29 阅读
  7. SonarQube 安装、部署及配置使用

    2024-04-21 06:48:02       33 阅读
  8. Dispatch架构

    2024-04-21 06:48:02       36 阅读
  9. MySQL 全表扫描成本计算

    2024-04-21 06:48:02       32 阅读
  10. Lustre架构介绍的阅读笔记-客户端

    2024-04-21 06:48:02       39 阅读
  11. Context Vector与Representation Learning

    2024-04-21 06:48:02       39 阅读