Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如何实现接口之间参数的关联? #3

Closed
chaoedu opened this issue Jul 12, 2017 · 3 comments
Closed

如何实现接口之间参数的关联? #3

chaoedu opened this issue Jul 12, 2017 · 3 comments

Comments

@chaoedu
Copy link

chaoedu commented Jul 12, 2017

登录过程中获取的token,可以在之后的testcase中使用

@debugtalk
Copy link
Member

这个功能是已经有了的。例如下面的形式,通过extract_binds将token提取出来并保存到user_token,然后后续的请求都可以直接用了。

- test:
    name: login with email to get user token
    request:
        url: /apis/apprest/v1/email_login
        method: POST
        headers:
            Content-Type: application/x-www-form-urlencoded
        data:
            email: $user_email
            password: $user_passwd
    extract_binds:
        user_token: content.data.token
    validators:
        - {"check": "status_code", "expected": 200}
        - {"check": "headers.content-type", "expected": "application/json;charset=UTF-8"}
        - {"check": "content.code", "expected": 0}
        - {"check": "content.message", "expected": "ok"}

- test:
    name: /api/users/user_id/home
    request:
        url: /api/users/$user_id/home
        params:
            page: 1
            page_size: 21
            token: $user_token
        method: GET
    validators:
        - {"check": "status_code", "expected": 200}
        - {"check": "headers.content-type", "expected": "application/json; charset=utf-8"}
        - {"check": "content.status", "expected": 0}
        - {"check": "content.status_msg", "expected": "ok"}
        - {"check": "content.items", "expected": 10, "comparator": "len_gt"}

@chaoedu
Copy link
Author

chaoedu commented Jul 12, 2017 via email

@debugtalk
Copy link
Member

@chaoedu 欢迎使用。

@debugtalk debugtalk changed the title 建议增加全局变量 如何实现接口之间参数的关联? Aug 4, 2017
debugtalk pushed a commit that referenced this issue Nov 2, 2017
lastest  pull from debugtalk
debugtalk pushed a commit that referenced this issue Nov 15, 2017
lastest  pull from debugtalk
debugtalk pushed a commit that referenced this issue Jun 4, 2019
lastest  pull from debugtalk
debugtalk pushed a commit that referenced this issue Mar 22, 2022
new pull request. 12.28
debugtalk pushed a commit that referenced this issue May 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants