Robot frame: is there a way to write dynamic test cases?

I am new to the structure of robots. I would like to create test cases dynamically without having a key value based approach.

Found some material that suggested the following:

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

I do not see add_step in the test case class, will continue to search and see if there are any solutions.

+5
source share
2 answers

An object TestSuitehas an attribute keywordsthat itself has a method createthat can be used to create new keywords.

api robot framework documentation gives this example :

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'])

The above test gives you the same test as if you wrote it like this:

*** Settings ***
Library    OperatingSystem

*** Test Cases ***
Should Activate Skynet
    [Tags]    smoke
    [Setup]    Set Environment Variable    SKYNET    activated
    Environment Variable Should Be Set    SKYNET
+4

,

0

Source: https://habr.com/ru/post/1680604/


All Articles