在robot fram中定义包含变量的关键字

2024-09-29 23:21:20 发布

您现在位置:Python中文网/ 问答频道 /正文

我目前正在为一个项目使用robot框架和Gherkin语言策略(在那时候给出)。在

我的功能文件如下:

*** Settings ***
Documentation
... In Order to eat a dessert safely, 
... As a king
... I want to not take a lethal dessert 

Library eat_or_pass.Eat_or_pass


*** Test cases ***
Lethal Dessert
    [Template]  The result of ${hungriness} should be ${dessert}
    very hungry apple pie   
    hungry      biscuit
    not very hungry apple


*** Keywords ***
The result of ${hungriness} should be ${dessert}
    Given the king is ${hungriness}
    Then the related dessert is ${dessert}

我想将关键字“Given the king is${hungriness}”链接到python模块Eat\u或中包含的python定义_通过.py目前实施情况如下:

^{pr2}$

运行robot framework时,出现以下错误: “致命甜点|失败| 找不到名为“Given the king is${hungriness}”的关键字。“ 我不知道怎么解决。有人能在这个问题上帮助我吗?在


Tags: orthetoisnotrobotpassgiven
2条回答

机器人代码:

*** Settings ***
Documentation
...    In Order to eat a dessert safely,
...    As a king
...    I want to not take a lethal dessert
Library    ./EatOrPass.py

*** Test Cases ***
Lethal Dessert
    [Template]    The Result Of ${hungriness} Should Be ${dessert}
    very hungry    apple pie
    hungry    biscuit
    not very hungry    apple

*** Keywords ***
The Result Of ${hungriness} Should Be ${dessert}
    Given The King Is ${hungriness}
    Then The Related Dessert Is ${dessert}

python库:

^{pr2}$

我建议您在python中使用CamelCase,在RF中使用4个空格(更好的可读性)。在

*** Keywords ***
The result of ${hungriness} should be ${dessert}
    Given The king Is Hungriness   

应该是因为国王饿了而不是因为国王${Hungriness}

^{pr2}$

相关问题 更多 >

    热门问题