Last active
September 27, 2018 12:39
-
-
Save flatfisher/866035f11f866949f8d7c257aa048c76 to your computer and use it in GitHub Desktop.
yaml でテストが書ける Tavernというテストツールがすごい ref: https://qiita.com/flatfisher/items/d8377711a30af1e9856b
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ pip install tavern[pytest] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
platform darwin -- Python 2.7.14, pytest-3.8.0, py-1.6.0, pluggy-0.7.1 -- /Users/kyohei/.pyenv/versions/2.7.14/envs/hogehoge/bin/python2.7 | |
cachedir: .pytest_cache | |
rootdir: /User/tmp/hello_world, inifile: | |
plugins: tavern-0.18.1 | |
collected 1 item | |
test_minimal.tavern.yaml::Get some fake data from the JSON placeholder API PASSED [100%] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test_name: login testing | |
stages: | |
- name: login | |
request: | |
url: https://hogehoge.com/login | |
json: | |
id: hogehoge | |
password: password | |
method: POST | |
headers: | |
content-type: application/json | |
response: | |
headers: | |
content-type: application/json | |
status_code: 200 | |
body: | |
status: 200 | |
expireStr: !anything | |
userId: !anything | |
token: !anything | |
expire: !anything | |
message: success | |
save: | |
body: | |
test_user_id: userId | |
test_login_token: token | |
- name: Get a user info | |
request: | |
url: https://hogehoge.com/user/{test_user_id} | |
method: GET | |
headers: | |
content-type: application/json | |
Authorization: "Bearer {test_login_token}" | |
response: | |
status_code: 200 | |
headers: | |
content-type: application/json | |
body: | |
result: | |
userId: "{test_user_id}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test_name: Get some fake data from the JSON placeholder API | |
stages: | |
- name: Make sure we have the right ID | |
request: | |
url: https://jsonplaceholder.typicode.com/posts/1 | |
method: GET | |
response: | |
status_code: 200 | |
body: | |
id: 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment