提供接口测试用例生成方法
Project description
interface_testcases
接口多参数测试用例生成
功能特性
- 正常值pairwise-2组合的用例
- 异常值用例
- 不传必选参数用例
- 不传全部可选参数的用例
使用指南
安装
方法1. pip安装:pip install interface-testcases
方法2. 下载源代码:git clone git@github.com:caiyizhang/interface_testcases.git
$ cd interface_testcases
$ pip install .
示例
from interface_testcases.testcases import InterfaceTestcases
# 传入参数一行代表一个参数,一个参数有3个属性。
# 前两个是列表,最后一个是布尔类型。分别是正常值、异常值和是否必选参数
params = [
[[1, 2], [0, 3], False],
[[-1, -2], [0, -3], True],
[[-3, 3], [-2, 4], False]
]
for case in InterfaceTestcases(params):
print(case)
# 结合pytest
import pytest
from interface_testcases.testcases import InterfaceTestcases
class Test1(object):
@pytest.mark.parametrize(['param_1', 'param_2', 'param_3', 'testcase_label'], [
value_list for value_list in InterfaceTestcases([
[['1', '10'], ['0', '7'], True],
[["1", '10', '100'], ['0', '101'], False],
[[None, '', 2161524184], ['1'], False],
[[None, '', '1', '11'], [0, 'f2rewrawr'], False]
])
])
def test_1(self, param_1, param_2, param_3, testcase_label):
params = {
'param_1': param_1,
'param_2': param_2,
'param_3': param_3
}
# params删除不传入的参数
params = {k: v for k, v in params.items() if v != 'no_param'}
if testcase_label == 'normal':
do_something_normal()
elif testcase_label == 'abnormal':
do_something_abnormal()
elif testcase_label == 'missing_required_param':
do_something_missging_requirde_param()
else:
pass
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file interface_testcases-0.2.3.tar.gz
.
File metadata
- Download URL: interface_testcases-0.2.3.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 82e2d40fed5cd5a51f1cbce912082164f35527aa24432f22b68c50f06811ed26 |
|
MD5 | a0de1060fdf442c06e673357b756f1e7 |
|
BLAKE2b-256 | f210cb128b6bb8f27835a04b17be8af5226aa7c0c35064a8378d9532b28afc3f |
File details
Details for the file interface_testcases-0.2.3-py3-none-any.whl
.
File metadata
- Download URL: interface_testcases-0.2.3-py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0826a9fa98aa17544656a202f5b4c36a0e2efdcd8e2014ccdbd3ac4b9f172752 |
|
MD5 | 55cf5ea9a02211c102eda29b8d61525b |
|
BLAKE2b-256 | adfdcaf627f12ede64ad8fddbe1eec711c7bbc44095f1133e1dfb17d77aaa200 |