mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-16 05:09:36 +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,4 +1,5 @@
|
||||
import logging
|
||||
from unittest.case import SkipTest
|
||||
|
||||
from httprunner import exception, response, testcase, utils
|
||||
from httprunner.client import HttpSession
|
||||
@@ -107,6 +108,12 @@ class Runner(object):
|
||||
setup_actions = testcase_dict.get("setup", [])
|
||||
teardown_actions = testcase_dict.get("teardown", [])
|
||||
|
||||
if "skipIf" in testcase_dict:
|
||||
skip_if_condition = testcase_dict["skipIf"]
|
||||
if self.context.exec_content_functions(skip_if_condition):
|
||||
skip_reason = "{} evaluate to True".format(skip_if_condition)
|
||||
raise SkipTest(skip_reason)
|
||||
|
||||
def setup_teardown(actions):
|
||||
for action in actions:
|
||||
self.context.exec_content_functions(action)
|
||||
|
||||
Reference in New Issue
Block a user