gpt4 book ai didi

selenium - Robot Framework - Selenium 库中 @BeforeMethod 注释的替代品是什么?

转载 作者:行者123 更新时间:2023-12-02 09:13:42 25 4
gpt4 key购买 nike

我需要在每个测试用例之前执行一些关键字。假设我有一个 .robot 文件,其中有 4 个测试用例,并且在执行这 4 个测试用例之前我需要运行关键字 4 次。在TestNG中,我们可以使用@BeforeMethod注解。我想知道可以使用 Robot Framework 做什么来做到这一点?

谢谢。

最佳答案

测试设置测试拆卸、测试超时关键字可用于指定每个测试用例之前需要调用的函数。
- 测试设置将分别充当Junit/Testng中的@Before/@BeforeMethod
- Test Teardown 将充当 JUnit/Testng 中的 @After/@AfterMethod
- [Setup] 关键字 - 如果您只想针对该测试用例执行@BeforeTest,则将使用该关键字。请引用下面的例子-

*** Settings ***
Library OperatingSystem
Suite Setup This Is Suite Startup Keyword
Suite Teardown This Is Suite TearDown Keyword
Test Setup This Is Before Test
Test Teardown This Is After Test

*** Keywords ***
This Is Suite Startup Keyword
Log To Console This Is Suite Startup Keyword

This Is Suite TearDown Keyword

Log To Console This Is Suite TearDown Keyword

This Is Before Test
Log To Console This Is Before Test

This Is After Test
Log To Console This Is After Test

This Is Special Execution Case
Log To Console This Is Special Execution Case


*** Test Cases ***
Test Case One
[setup] This Is Special Execution Case
Log To Console This Is My Test Case 1

Test Case Two
Log To Console This Is My Test Case 2

Test Case Three
Log To Console This Is My Test Case 3

更多详情请参阅Robot Framework User Guide初始化文件和 2.4.5 套件设置和拆卸部分。

关于selenium - Robot Framework - Selenium 库中 @BeforeMethod 注释的替代品是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53719856/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com