How can I implement Gherkin data tables in Robot Framework?
The following snippet should pass two sets of (n, is_prime) parameters to Keywords in order to verify that:
is_prime(5) = True
is_prime(6) = False
*** Test Cases ***
Function should verify prime number
Given I have a positive integer and is_prime() function
| n | is_prime |
| 5 | True |
| 6 | False |
When I check whether n is prime
Then is_prime() should verify this
Note: This is not about Scenario Outline. I found https://gist.github.com/Tset-Noitamotua/8f06bd490918a56b0485630016aef60b and can write Robot test using Examples table.
Here is a Python function, which I use for checking prime number:
import math
def is_prime(num):
if num < 2:
return False
sqr = int(math.floor(math.sqrt(num)))
for i in range(2, sqr + 1):
if num % i == 0:
return False
return True
In short: Multi-line gherkin is not supported when using Test Template feature.
In Robot Framework Gherkin are Robot Framework keywords within the context of a single Test Case. A Test Template Feature only supports a single keyword. So either you create a single line keyword from your multi-line Gherkin or accept that the combination isn't possible.