Skip to main content

测试脚本自动生成项目

用例写法

通用参数

本地执行

执行&调用

引用方式

import sys
from os.path import abspath, join, dirname
sys.path.insert(0, join(abspath(dirname(__file__)), '../..'))

..代表上级目录

../..代表上上级目录

以此类推

代码环境

python 3.*

依赖包

  • 安装

pip install requests

目录结构

将执行脚本与base.py脚本放于同一目录下

沙盒环境

脚本执行方式

假设生成的文件名为: test_break_username.py

那么执行方式为: python test_break_username.py

任务项&进度

任务名称 产出 功能 是否完成
测试基类 base.py 用于业务测试脚本继承 完成
获取数据类 get_req_data.py 用于获取请求数据 完成
json module解析类 json_modify.py 用于解析json module数据 未完成
触发生成测试脚本文件 generate_script.py 用来生成对应接口的测试脚本文件 完成
独立执行测试脚本命令 - 用于调用执行.py脚本 完成
组装TestSuite并生成测试报告数据 generate_test_data.py 用于生成批量测试结果,持久化数据 未完成

调用顺序

  1. generate_script.py 生成执行脚本

  2. 执行test_this_is_the_path.py 脚本

  3. base.py 进入base类

  4. 调用获取数据类,get_req_data.py json_modify.py

  5. 执行base.py中的用例

  6. 继续执行test_this_is_the_path.py中的用例

  7. 返回测试结果

可以通过命令行运行:模块、类、或者单个测试方法,具体的操作是如下:

运行测试模块:python -m unittest test_module1 test_module2

运行测试类:python -m unittest test_module.TestClass

运行测试方法:python -m unittest test_module.TestClass.test_method

  • 通用模板
  • 执行方式
  • 返回结果组装
  • 调用上报接口
方法 检查一下 新的
assertEqual(a, b) a == b
assertNotEqual(a, b) a != b
assertTrue(x) bool(x) is True
assertFalse(x) bool(x) is False
assertIs(a, b) a is b 2.7
assertIsNot(a, b) a is not b 2.7
assertIsNone(x) x is None 2.7
assertIsNotNone(x) x is not None 2.7
assertIn(a, b) a in b 2.7
assertNotIn(a, b) a not in b 2.7
assertIsInstance(a, b) isinstance(a, b) 2.7
assertNotIsInstance(a, b) not isinstance(a, b) 2.7

更具体的

方法 检查一下 新的
assertAlmostEqual(a, b) round(a-b, 7) == 0
assertNotAlmostEqual(a, b) round(a-b, 7) != 0
assertGreater(a, b) a > b 2.7
assertGreaterEqual(a, b) a >= b 2.7
assertLess(a, b) a < b 2.7
assertLessEqual(a, b) a <= b 2.7
assertRegexpMatches(s, r) r.search(s) 2.7
assertNotRegexpMatches(s, r) not r.search(s) 2.7
assertItemsEqual(a, b) 排序(a)==排序(b)并使用不可用的objs 2.7
assertDictContainsSubset(a, b) 所有在键/值对一个在存在b 2.7

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ibase-0.0.2.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ibase-0.0.2-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file ibase-0.0.2.tar.gz.

File metadata

  • Download URL: ibase-0.0.2.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.7

File hashes

Hashes for ibase-0.0.2.tar.gz
Algorithm Hash digest
SHA256 4f21cf6c76094e6e230aaa270dfb1486603bc929f68b44f95dc8d5487d5ee428
MD5 7b831e33142e7df82abcd602560a9c2c
BLAKE2b-256 4558741e2052b233dd7b5721a4abd46ba5bb44982f158dfaf650c870722ca00d

See more details on using hashes here.

File details

Details for the file ibase-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: ibase-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 11.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.7

File hashes

Hashes for ibase-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 db60220b104dc6e5aea7905bfdce64b85b20e77a80afb1921dc915648ae710f7
MD5 693daf0ede715c3055a53c359e65b2bd
BLAKE2b-256 a65962e97625531c03dd3e96c74a6144c474425fa49e76506e5a3fda791d40ee

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 files

0.0.1

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page