Skip to main content

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

Metadata

Release files for interface-testcases 0.2.3

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

Source distribution (sdist)

Source distribution for interface-testcases 0.2.3
File Size Uploaded Provenance Actions
interface_testcases-0.2.3.tar.gz 3.7 kB Without provenance Details for interface_testcases-0.2.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for interface-testcases 0.2.3
File Interpreter ABI Platform Actions
interface_testcases-0.2.3-py3-none-any.whl Python 3 none any Details for interface_testcases-0.2.3-py3-none-any.whl

Total release size: 8.1 kB

Release files / interface_testcases-0.2.3.tar.gz

Download URL interface_testcases-0.2.3.tar.gz
Size 3.7 kB
Tags Source
SHA-256 checksum
How to use checksums
82e2d40fed5cd5a51f1cbce912082164f35527aa24432f22b68c50f06811ed26
BLAKE2b-256 checksum
How to use checksums
f210cb128b6bb8f27835a04b17be8af5226aa7c0c35064a8378d9532b28afc3f
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / interface_testcases-0.2.3-py3-none-any.whl

Download URL interface_testcases-0.2.3-py3-none-any.whl
Size 4.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0826a9fa98aa17544656a202f5b4c36a0e2efdcd8e2014ccdbd3ac4b9f172752
BLAKE2b-256 checksum
How to use checksums
adfdcaf627f12ede64ad8fddbe1eec711c7bbc44095f1133e1dfb17d77aaa200
Upload date
Uploaded using Trusted Publishing?
What is 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

Security for interface-testcases 0.2.3

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.

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