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

Metadata

Release files for ibase 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ibase 0.0.2
File Size Uploaded Provenance
ibase-0.0.2.tar.gz 10.1 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for ibase 0.0.2
File Interpreter ABI Platform
ibase-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 22.0 kB

Release files / ibase-0.0.2.tar.gz

Download URL ibase-0.0.2.tar.gz
Size 10.1 kB
Tags Source
SHA-256 checksum
How to use checksums
4f21cf6c76094e6e230aaa270dfb1486603bc929f68b44f95dc8d5487d5ee428
BLAKE2b-256 checksum
How to use checksums
4558741e2052b233dd7b5721a4abd46ba5bb44982f158dfaf650c870722ca00d
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / ibase-0.0.2-py3-none-any.whl

Download URL ibase-0.0.2-py3-none-any.whl
Size 11.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
db60220b104dc6e5aea7905bfdce64b85b20e77a80afb1921dc915648ae710f7
BLAKE2b-256 checksum
How to use checksums
a65962e97625531c03dd3e96c74a6144c474425fa49e76506e5a3fda791d40ee
Upload date
Uploaded using Trusted Publishing?
What is 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

Security for ibase 0.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page