如何在 Robot Framework 中的每一步后 运行
How to run something after every step in Robot Framework
我想在 Robot Framework 中的测试用例的每一步之后检查一些东西。我包括一个虚拟示例来表示我所指的内容:
*** Test Cases ***
Order From Somewhere
[Tags] whatever tags here
Step1
#Grab Exception
Step2
#Grab Exception
Step3
#Grab Exception
Step4
#Grab Exception
Step5
#Grab Exception
Step6
#Grab Exception
Step7
我假设有一些方法可以在每个步骤之后执行“#Grab Exception”,但方式很好。
提前感谢您的帮助。
您可以定义自己的关键字来执行此操作,例如:
*** Test Cases ***
Test Special Keywords
Special Keyword Sleep 5 seconds
Special Keyword Log <b>This is another keyword</b> HTML
*** Keywords ***
Special Keyword
[Arguments] ${kw} @{arguments}
Run Keyword ${kw} @{arguments}
Grab Exception
Grab Exception
Log Called <i>Grab Exception</i> HTML
您可以在设置区域中使用“测试拆解”选项添加如下内容:
Run Keyword If Test Failed or Passed <name of the kw>
--- 你可以使用其中之一通过或失败或者你可以使用除非满足条件。
例如如下:
*** Settings ***
Test Setup Open Application App A
Test Teardown Close Application
*** Test Cases ***
Default values
[Documentation] Setup and teardown from setting section
Do Something
Overridden setup
[Documentation] Own setup, teardown from setting section
[Setup] Open Application App B
Do Something
No teardown
[Documentation] Default setup, no teardown at all
Do Something
[Teardown]
No teardown 2
[Documentation] Setup and teardown can be disabled also with special value NONE
Do Something
[Teardown] NONE
Using variables
[Documentation] Setup and teardown specified using variables
[Setup] ${SETUP}
Do Something
[Teardown] ${TEARDOWN}
我想在 Robot Framework 中的测试用例的每一步之后检查一些东西。我包括一个虚拟示例来表示我所指的内容:
*** Test Cases ***
Order From Somewhere
[Tags] whatever tags here
Step1
#Grab Exception
Step2
#Grab Exception
Step3
#Grab Exception
Step4
#Grab Exception
Step5
#Grab Exception
Step6
#Grab Exception
Step7
我假设有一些方法可以在每个步骤之后执行“#Grab Exception”,但方式很好。
提前感谢您的帮助。
您可以定义自己的关键字来执行此操作,例如:
*** Test Cases ***
Test Special Keywords
Special Keyword Sleep 5 seconds
Special Keyword Log <b>This is another keyword</b> HTML
*** Keywords ***
Special Keyword
[Arguments] ${kw} @{arguments}
Run Keyword ${kw} @{arguments}
Grab Exception
Grab Exception
Log Called <i>Grab Exception</i> HTML
您可以在设置区域中使用“测试拆解”选项添加如下内容:
Run Keyword If Test Failed or Passed <name of the kw>
--- 你可以使用其中之一通过或失败或者你可以使用除非满足条件。 例如如下:
*** Settings ***
Test Setup Open Application App A
Test Teardown Close Application
*** Test Cases ***
Default values
[Documentation] Setup and teardown from setting section
Do Something
Overridden setup
[Documentation] Own setup, teardown from setting section
[Setup] Open Application App B
Do Something
No teardown
[Documentation] Default setup, no teardown at all
Do Something
[Teardown]
No teardown 2
[Documentation] Setup and teardown can be disabled also with special value NONE
Do Something
[Teardown] NONE
Using variables
[Documentation] Setup and teardown specified using variables
[Setup] ${SETUP}
Do Something
[Teardown] ${TEARDOWN}