I got a very specific scenario, where I'm inserting some data to the database(e.g. let's say 3 inserts and each one of them returns some ID) and based on a return value I want to create dynamically test cases for those return values E.g.
*** Variables ***
@{result} ${EMPTY}
*** Test Cases ***
Some dummy sql inserts
${result} Insert sql statements dt1 dt2 dt3 #e.g. return ['123', '456', '789']
Verify some ids
# NOPE, sorry i can't use [Template] because each iteration is not marked on a report as a "TEST" but as a "VAR"
Verify if ids exist somewhere ${result} #This keyword execution should create another 3 test cases, one for each item from ${result} list
*** Keywords ***
Insert sql statement
[Arguments] @{data}
Create List ${result}
FOR ${elem} IN @{data}
${return_id} SomeLib.Execute SQL INSERT INTO some_table(some_id) VALUES (${elem})
Append To List ${result} ${return_id}
END
[Return] ${result}
Verify if ids exist somewhere
[Arguments] ${some_list_of_ids}
FOR ${id} IN @{some_list_of_ids}
So some stuff on ${id}
END
I was trying to figure out how to do that by reffering to robot API documentation but without any success.
Can you please tell/advise if it's feasible, if so, than how can I achieve that.
So far I've figured out that there might be 2 ways of doing this:
- by creating a listener
- by creating own keyword
In both cases, I have to put the logic there, but can't figure out how to create test cases on-the-fly.
Help, please? :)
P.S. Some examples are more than welcome. Thanks in advance