Katalon变量类型[Variable Types](V5.10.0)

Katalon支持的变量类型有三种,如下表格:

变量类型 说明
私有变量(Private Variable) 私有变量只能在定义它的测试用例范围中访问
本地变量(Local Variable) 本地变量(即公共变量),能够在定义它的测试用例中作为一个公开的参数供访问
全局变量(Global Variable) 一个全局变量能在整个测试项目中任意测试用例都能访问到

私有变量(Private Variable)

在脚本视图中,测试用例定义私有变量,而这个私有变量只能在当前定义的这个Groovy类中进行访问,如下例:

// x is defined as a variable of String type
String x = "Hello"; 

// y is defined as a variable of int type
int y = 5;

// The value of the variables are printed to the console 
println(x);
println(y);

本地变量(Local Variable)

Katalon可以通过用例编辑器在Varialbes标签页中对本地变量进行管理。
1、在测试用例中选择Variables标签,并点击Add

Katalon变量类型[Variable Types](V5.10.0)_第1张图片
Variables

2、此时编辑器中会新增一行,修改该行的值,变量名字、类型、初始值。

Katalon变量类型[Variable Types](V5.10.0)_第2张图片
initialize

3、此时该变量即可作为一个参数,供该测试用例进行访问、使用。(比如说,作为一个测试用例的输入值或者作为执行时绑定的数据等等)。

全局变量(Global Variable)

  • 只在5.3以下的版本中称之为全局变量
  • 5.4及以上的版本中称之为执行配置文件(Execution Profile)

可以在Global Variables视图中管理全局变量。
1、展开全局变量编辑视图(Global Variable),点击Add

Katalon变量类型[Variable Types](V5.10.0)_第3张图片
Global Variable View.

2、此时会弹出全局变量的新增会话窗口,编辑对应的每一项,点击OK

Katalon变量类型[Variable Types](V5.10.0)_第4张图片
New Variable

3、成功添加了一个全局变量。

Katalon变量类型[Variable Types](V5.10.0)_第5张图片
Global Variable List

4、此时,该全局变量可以被该项目中的任何测试用例进行访问、使用。

你可能感兴趣的:(Katalon变量类型[Variable Types](V5.10.0))