如何在Robot Framework中实现Gherkin数据表?
以下代码段应将两组(n,is_prime)参数传递给关键字,以便验证:
is_prime(5)=真
is_prime(6)=假
*** 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
Run Code Online (Sandbox Code Playgroud)
注意:这与场景大纲无关.我发现https://gist.github.com/Tset-Noitamotua/8f06bd490918a56b0485630016aef60b,并且可以使用机器人编写测试实例表.
这是一个Python函数,我用它来检查素数:
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 …Run Code Online (Sandbox Code Playgroud)