apipost-runtime8

1.0.26 • Public • Published

A-Design Logo

🚀 apipost-runtime8

apipost-runtime8 支持单接口http请求、自动化测试。其支持的选项含义可参考下方的demo注释。 为apipost8准备

Install

$ npm install apipost-runtime8

Usage

let iterationData = [
    {
        "email": "1234@qq.com",
        "password": "1234",
        "age": 12
    },
    {
        "email": "1234@qq.com",
        "password": "1234",
        "age": 11
    },
    {
        "email": "1234@qq.com",
        "password": "1234",
        "age": 36
    }
];

let myCollection = new Collection([
    {
        "test_id": "9a017559-967a-4235-898c-5541ffeb7659",
        "event_id": "91e55b90-b79c-43dd-aecd-7c9294cd5b37",
        "type": "api",
        "data": {
            "parent_id": "90de3444-250a-4808-a37f-6715b6add4b1",
            "target_id": "dee9ecb8-b062-4bb2-a694-5edb1c1eaaed",
            "method": "GET",
            "url": "https://2021.apis.cloud/get.php"
        },
        "children": []
    }
], { iterationCount: 4 });
let myRuntime = new Runtime();

myRuntime.run(myCollection.definition, {
    project: {
        request: {
            "header": {"parameter":[
                {
                    "is_checked": "1",
                    "type": "Text",
                    "key": "global-header",
                    "value": "{{age}}",
                    "description": ""
                }
            ]},
            "query": {"parameter":[
                {
                    "is_checked": "1",
                    "type": "Text",
                    "key": "",
                    "value": "",
                    "description": ""
                }
            ]},
            "body": {"parameter":[
                {
                    "is_checked": "1",
                    "type": "Text",
                    "key": "",
                    "value": "",
                    "description": ""
                }
            ]},
            "auth": {
                "type": "noauth",
                "kv": {
                    "key": "",
                    "value": ""
                },
                "bearer": {
                    "key": ""
                },
                "basic": {
                    "username": "",
                    "password": ""
                }
            }
        },
        "script": {
            "pre_script_switch": true,
            "post_script_switch": true,
            "pre_script": `pm.globals.set("age", '12');`,
            "post_script": `//apt.assert('response.raw.responseText==\"test\"');`
        }
    }, // 全局参数
    collection: [target1, target2, target3], // 当前流程所需的接口以及父目录集合
    combined_id: 0, // 测试套件ID,单测试用例的话传 0
    test_events: [{
        test_id: 'db5363e4-046a-4ce2-9d6f-89ef0b463026',
        name: '测试计划'
    }], // 测试用例集合,如果是测试套件,此处传数组(单流可以传对象)
    default_report_name: '测试报告',
    user: { // 当前执行的用户信息
        uuid: 'bcad1d6f-7a6c-4a60-a2fc-d59c9ad11d82',
        nick_name: 'Apipost'
    },
    env: {
        "env_id": "225e305cd401000",
        "env_name": "新建环境",
        "env_pre_url": "",
        environment: {
            "title": "我是标题"
        }
    }, 
    globals: {
        "address": "我是地址"
    }, // 当前公共变量
    sleep: 0, // 间隔时间
    iterationData: iterationData, // 当前迭代的excel导入数据
    iterationCount: 4, // 当前迭代次数
});

Readme

Keywords

Package Sidebar

Install

npm i apipost-runtime8

Weekly Downloads

3

Version

1.0.26

License

ISC

Unpacked Size

258 kB

Total Files

4

Last publish

Collaborators

  • wjzhangq