mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-16 22:37:38 +08:00
#96: refactor skip feature:
1, with skip keyword, skip current test unconditionally; 2, with skipIf keyword, you can skip current test with condition; condition evaluation can be defined in debugtalk.py function.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import hashlib
|
||||
import hmac
|
||||
import json
|
||||
import os
|
||||
import random
|
||||
import string
|
||||
import time
|
||||
@@ -40,3 +41,10 @@ def sum_status_code(status_code, expect_sum):
|
||||
sum_value += int(digit)
|
||||
|
||||
assert sum_value == expect_sum
|
||||
|
||||
os.environ["TEST_ENV"] = "PRODUCTION"
|
||||
|
||||
def skip_test_in_production_env():
|
||||
""" skip this test in production environment
|
||||
"""
|
||||
return os.environ["TEST_ENV"] == "PRODUCTION"
|
||||
|
||||
@@ -68,8 +68,29 @@
|
||||
- {"check": "content.success", "comparator": "eq", "expect": false}
|
||||
|
||||
- test:
|
||||
name: create user which existed (skipped)
|
||||
skip: True
|
||||
name: create user which existed (skip unconditionally)
|
||||
skip: skip this test unconditionally
|
||||
times: 2
|
||||
request:
|
||||
url: http://127.0.0.1:5000/api/users/1000
|
||||
method: POST
|
||||
headers:
|
||||
Content-Type: application/json
|
||||
device_sn: 'HZfFBh6tU59EdXJ'
|
||||
token: $token
|
||||
json:
|
||||
name: "user1"
|
||||
password: "123456"
|
||||
validate:
|
||||
- "eq": ["status_code", 500]
|
||||
- sum_status_code: ["status_code", 5]
|
||||
- "eq": ["content.success", false]
|
||||
- {"check": "status_code", "comparator": "eq", "expect": 500}
|
||||
- {"check": "content.success", "comparator": "eq", "expect": false}
|
||||
|
||||
- test:
|
||||
name: create user which existed (skip with condition)
|
||||
skipIf: ${skip_test_in_production_env()}
|
||||
times: 2
|
||||
request:
|
||||
url: http://127.0.0.1:5000/api/users/1000
|
||||
|
||||
Reference in New Issue
Block a user