开发二次关键字,add test case 用于执行一个用例,而不是按RF框架本身的用例个数执行
from __future__ import print_function
# from .version import VERSION
# __version__ = VERSION
class DynamicTestCase(object):
ROBOT_LISTENER_API_VERSION = 3
ROBOT_LIBRARY_SCOPE = 'TEST SUITE'
# ROBOT_LIBRARY_VERSION = __version__
def __init__(self):
self.ROBOT_LIBRARY_LISTENER = self
self.current_suite = None
def _start_suite(self, suite, result):
# save current suite so that we can modify it later
self.current_suite = suite
def add_test_case(self, name, kwname, *args):
"""Adds a test case to the current suite
'name' is the test case name
'kwname' is the keyword to call
'*args' are the arguments to pass to the keyword
Example:
add_test_case Example Test Case
... log hello, world WARN
"""
tc = self.current_suite.tests.create(name=name)
tc.body.create_keyword(name=kwna

本文介绍如何在Robotframework中进行框架改写,通过开发二次关键字`add test case`,实现按需执行单个用例的功能,而非默认的整个用例集执行。
最低0.47元/天 解锁文章
873

被折叠的 条评论
为什么被折叠?



