Git Product home page Git Product logo

apitesting's Introduction

ApiTesting

此框架是基于Python+Pytest+Requests+Allure+Yaml+Json实现全链路接口自动化测试。

主要流程:

解析接口数据包 ->生成接口基础配置(yml) ->生成测试用例(yaml+json) ->生成测试脚本(.py) ->运行测试(pytest) ->生成测试报告(allure)

测试流程:

初始化请求 ->处理接口基础信息 ->读取前置接口用例 ->发送前置接口 ->处理当前接口数据 ->发送当前接口 ->检查接口返回

ApiTesting全链路接口自动化测试框架 - 初版(一)

介绍:https://www.cnblogs.com/leozhanggg/p/14373878.html

ApiTesting全链路接口自动化测试框架 - 新增数据库校验(二)

介绍:https://www.cnblogs.com/leozhanggg/p/14522084.html

ApiTesting全链路接口自动化测试框架 - 实战应用

介绍:https://www.cnblogs.com/leozhanggg/p/14519800.html

运行配置说明:

运行项目名 project_name: PyDemo

运行模式: auto_switch: 2

0 - 不开启自动生成测试用例功能,将直接运行测试

1 - 根据手工编写用例,自动生成测试脚本,然后运行测试

2 - 根据接口抓包数据,自动生成测试用例和测试脚本,然后运行测试

3 - 根据接口抓包数据,自动生成测试用例和测试脚本,但不运行测试

注意:目前解析仅支持(.chlsj)格式,请使用Charles工具抓包导出JSON Session File

扫描测试用例目录(且仅当auto_switch=1时有用) scan_dir:

使用模糊匹配测试用例(空则匹配所有) pattern:

执行并发线程数(0表示不开启) process: 0

失败重试次数(0表示不重试) reruns: 0

本轮测试最大允许失败数(超出则立即结束测试) maxfail: 20

接口调用间隔时间(s) interval: 1

测试结果校验方式说明(共5种方式):

1 - no_check:不做任何校验

2 - check_code:仅校验接口返回码code

3 - check_json:校验接口返回码code,并进行json格式比较返回结果(默认方式)

4 - entirely_check:校验接口返回码code,并进行完整比较返回结果

5 - regular_check:校验接口返回码code,并进行正则匹配返回结果

apitesting's People

Contributors

leozhanggg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

apitesting's Issues

运行 pytest 报错

==================================================================================== ERRORS ====================================================================================
_______________________________________________________ ERROR collecting PyDemo/testcase/perRelated/test_addAudltCard.py _______________________________________________________
ImportError while importing test module '/Users/xianxian/Desktop/work/ApiTesting/PyDemo/testcase/perRelated/test_addAudltCard.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
PyDemo/testcase/perRelated/test_addAudltCard.py:9: in
from comm.utils.readYaml import read_yaml_data
E ModuleNotFoundError: No module named 'comm'
_______________________________________________________ ERROR collecting PyDemo/testcase/register/test_addOrUpCurBact.py _______________________________________________________
ImportError while importing test module '/Users/xianxian/Desktop/work/ApiTesting/PyDemo/testcase/register/test_addOrUpCurBact.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
PyDemo/testcase/register/test_addOrUpCurBact.py:9: in
from comm.utils.readYaml import read_yaml_data
E ModuleNotFoundError: No module named 'comm'
_________________________________________________________ ERROR collecting PyDemo/testcase/register/test_findParam.py __________________________________________________________
ImportError while importing test module '/Users/xianxian/Desktop/work/ApiTesting/PyDemo/testcase/register/test_findParam.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
PyDemo/testcase/register/test_findParam.py:9: in
from comm.utils.readYaml import read_yaml_data
E ModuleNotFoundError: No module named 'comm'
____________________________________________________ ERROR collecting PyDemo/testcase/register/test_getAdultCurbactList.py _____________________________________________________
ImportError while importing test module '/Users/xianxian/Desktop/work/ApiTesting/PyDemo/testcase/register/test_getAdultCurbactList.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
PyDemo/testcase/register/test_getAdultCurbactList.py:9: in
from comm.utils.readYaml import read_yaml_data
E ModuleNotFoundError: No module named 'comm'
_______________________________________________________ ERROR collecting PyDemo/testcase/register/test_initCanSelInfo.py _______________________________________________________
ImportError while importing test module '/Users/xianxian/Desktop/work/ApiTesting/PyDemo/testcase/register/test_initCanSelInfo.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
PyDemo/testcase/register/test_initCanSelInfo.py:9: in
from comm.utils.readYaml import read_yaml_data
E ModuleNotFoundError: No module named 'comm'
___________________________________________________________________ ERROR collecting config/test_template.py ___________________________________________________________________
ImportError while importing test module '/Users/xianxian/Desktop/work/ApiTesting/config/test_template.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
config/test_template.py:10: in
from comm.unit.initializePremise import init_premise
comm/unit/initializePremise.py:12: in
from comm.unit import apiSend, readRelevance, replaceRelevance
comm/unit/apiSend.py:10: in
from comm.unit import apiMethod
comm/unit/apiMethod.py:12: in
from requests_toolbelt import MultipartEncoder
E ModuleNotFoundError: No module named 'requests_toolbelt'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 6 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
=============================================================================== 6 error in 0.57s ====================

录制脚本后无法运行成功,希望进交流群得到作者或群友的答疑解惑

1.使用Charles录制网易邮箱登录,执行时遇到各种报错,export 整个文件夹为.chlsj文件,会报错json无法解析,只导出api为.chlsj文件,又提示 Invalid header,不知道是Charles录制操作问题还是自动化测试框架的问题,报错如下:
raise ValueError('Invalid header name %r' % (header,))
E ValueError: Invalid header name b':method'

2.作者的pydemo的host是本地的,运行会报错

QQ申请加入了交流群,麻烦通过一下,希望在群里沟通解决问题

求教chls文件导出问题

您好,请教一下:
1、Charles导出chls文件是从FilesExport Sesssion导出的不?
2、看您工程chls文件是一个列表,导出的文件有本地编辑处理不?我从Files
Export Sesssion导出的文件打开是乱码的,格式与您的chls文件差别较大。

谢谢。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.