【问题标题】:Set variable based on currently active test case根据当前活动的测试用例设置变量
【发布时间】:2018-02-08 15:10:00
【问题描述】:

我有以下情况。 Test.robot 是我的机器人套件,有 4 个测试用例。

***Settings**

Resource  Python Resource files


Suite Setup  ${xyz}
Suite Teardown  ${xyz} 

Test Setup  ${Xyz}

***Variables***

/*This is pointing to the folder with my data files*/
${data}  {CURDIR}/


*** Test Cases ***

Test_case1
Test_case2
Test_case3 
Test_case4

我有一个包含文件夹的目录 1.Test_Case1 2.Test_Case2 3.Test_Case3 4.Test_Case4 test.robot(我的机器人套件)

以上 4 个文件夹包含我的测试(test_case1、test_case2、test_case3、test_case4)在运行时将访问的数据文件。我不确定如何设置变量,以便在运行 test.robot 套件时动态访问特定的测试文件夹。

我的意思是,当我运行 test.robot 时,所有四个测试(test_case1、test_case2 等)都会运行。我不确定如何设置变量 ${data} 以便在特定测试用例运行时动态访问正确的 test_case 文件夹

【问题讨论】:

    标签: automation robotframework


    【解决方案1】:

    您可以使用automatic variable ${TEST NAME} 来检索当前活动的测试用例的名称,并使用从该变量中提取的数据设置您自己的变量。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-12-06
      • 1970-01-01
      • 2021-11-07
      • 1970-01-01
      • 2021-11-15
      • 2022-10-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多