机器人框架:有没有办法编写动态测试用例?

2024-03-11

我对机器人框架很陌生。我想动态创建测试用例,而无需输入键值驱动方法。

发现一些材料提出以下建议:

suite = TestSuite('Example suite', doc='...')
tc = TestCase('Example test')
tc.add_step(TestStep('Log', args=['Hello, world!'])
suite.add_test(tc)

我在测试用例类中没有看到add_step,将继续四处看看是否有任何解决方案。


The TestSuite对象有一个keywords属性本身有一个create可用于创建新关键字的方法。

The 机器人框架API文档 http://robot-framework.readthedocs.io/en/3.0/autodoc/robot.running.html给出这个example http://robot-framework.readthedocs.io/en/3.0/autodoc/robot.running.html#examples:

from robot.api import TestSuite

suite = TestSuite('Activate Skynet')
suite.resource.imports.library('OperatingSystem')
test = suite.tests.create('Should Activate Skynet', tags=['smoke'])
test.keywords.create('Set Environment Variable', args=['SKYNET', 'activated'], type='setup')
test.keywords.create('Environment Variable Should Be Set', args=['SKYNET'])

上面为您提供了相同的测试,就好像您是这样编写的:

*** Settings ***
Library    OperatingSystem

*** Test Cases ***
Should Activate Skynet
    [Tags]    smoke
    [Setup]    Set Environment Variable    SKYNET    activated
    Environment Variable Should Be Set    SKYNET
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

机器人框架:有没有办法编写动态测试用例? 的相关文章

随机推荐