接口自动化测试框架 -- reudom

一曲冷凌霜 提交于 2020-07-27 06:07:50

reudom

Automated testing framework based on requests and unittest interface.

基于 Unittest 和 Requests 的 接口自动化测试框架

介绍

基于Unittest/Requests的接口自动化测试库

  • 提供脚手架,快速生成接口自动化测试项目。
  • 自动生成HTML测试报告。
  • 支持用例参数化。
  • 支持用例失败重跑
  • 对原生Requests库API无损

加入我们。群。642830685,免费领取最新软件测试大厂面试资料和Python自动化、接口、框架搭建学习资料!有技术大牛解惑,同行一起交流

目录架构

myreudom/
├── test_case/
│   ├── test_sample.py
├── reports/
└── run.py

 

test_dir/
reports/
run.py

 

安装教程

> pip install reudom

If you want to keep up with the latest version, you can install with github repository url:  

 

> pip install -U git+https://github.com/SeldomQA/reudom.git@master

 

创建项目

>reudom --project myreudom

运行项目:

> reudom -r run.py
Python 3.7.1

                     _                 
                    | |                
  _ __ ___ _   _  __| | ___  _ __ ___  
 | '__/ _ | | | |/ _` |/ _ \| '_ ` _ \ 
 | | |  __| |_| | (_| | (_) | | | | | |
 |_|  \___|\__,_|\__,_|\___/|_| |_| |_|                             
 --------------------------------------
                            @itest.info

generated html file:/Users/work/reports/2019_12_22_14_51_57_result.html
.1

查看报告

你可以到 myreudom\reports\ 目录查看测试报告。

reports 文件夹可以不用自己去创建,它会在你执行run.py时自动创建此文件夹

simple demo

请查看 demo/test_sample.py 文件

import reudom


class test(reudom.TestCase):
    def setUp(self):
        self.url = 'http://www.baidu.com'

    def test01(self):
        rep = reudom.request('get', url=self.url, headers=self.headers())
        result = rep.json()
        self.assertEqual(result['status'], '200')


if __name__ == '__main__':
    reudom.main("test_sample.py")

说明:

  • 创建测试类必须继承  reudom.TestCase 。
  • 测试用例文件命名必须以  test  开头。
  • reudom引入了 post 、 get 、 head 、 patch 、 put 、 delete 、 options 等方法。

main() 方法

import reudom

# ...

if __name__ == '__main__':

    seldom.main(
              path="./",
              title="接口自动化测试用例", 
              description="详细测试结果:", 
              debug=False,
              rerun=0,
              save_last_run=False,
    )

 

说明:

False
0
False

 

Run the test

import reudom

reudom.main(path="./")  # 当前目录下的所有测试文件
reudom.main(path="./test_dir/")  # 指定目录下的所有测试文件
reudom.main(path="./test_dir/test_sample.py")  # 指定目录下的测试文件
reudom.main(path="test_sample.py")  # 指定当前目录下的测试文件

 说明: 

 

test
__init__.py

 

跳过用例

import reudom


class YouTest(reudom.TestCase):

    @reudom.skip("跳过这条用例的执行")
    def test_case(self):
        """a simple test case """
        #...

 

在PyCharm里使用

  • 当你使用PyCharm编译器或其他Python编译器时,您只需要使用 pip install reudom 安装后在你项目的文件夹内创建 .py 文件里 import reudom 就可以了
  • 如果你需要正式的运行起来,只需在项目跟目录里创建 run.py 里使用上面的 main 方法取运行就可以啦;运行时会自动的在 run.py 的同级目录生成 reports 文件夹生成的 测试报告 就在里面!

 

AES加密

import reudom

 

reudom.aesCrypt(
                    key='16位', 
                    model='加密模式', 
                    iv='CBC模式需要它', 
                    encode_='默认GBK')
                    .aesEncrypt('传入需要加密的明文')

 

key
model
iv
encode_
text
import reudom

reudom.aesCrypt(key='1234567890123456', model='CBC', iv='1234567890123456', encode_='GBK').aesEncrypt(text='123')


控制台:
/usr/bin/python3 /Users/yuanbaolei/work/GitHub/reudom/CryptoAESAES/Cipher/aesEncrypt.py
15tT+y0b+lJq2HIKUjsvvg==

Process finished with exit code 0

  

加入我们。群。642830685,免费领取最新软件测试大厂面试资料和Python自动化、接口、框架搭建学习资料!有技术大牛解惑,同行一起交流

  

 

 

 

 

  

  

  

 

 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!