Skip to main content

提供接口测试用例生成方法

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

interface_testcases-0.2.3.tar.gz (3.7 kB view hashes)

Uploaded Source

Built Distribution

interface_testcases-0.2.3-py3-none-any.whl (4.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page