Introduction to the rules for using variables in the Lim test platform

1. Introduction to Lim Test Platform

The Lim test platform is a lightweight interface test platform, and it is also one of the few languages ​​that use python as the back-end interface construction.

Just like its name, we hope to "make a difference" when carrying out interface testing! Let users operate less but build more efficiently. Therefore, we have made many optimizations and innovations in interaction details and some bold designs.

Lim test platform warehouse address:

Gitee (domestic mirror image)

Github


2. How to use variables

The Lim test platform can define and output a variable by adding the global variable step, the output variable in the interface step, and SQL. The output variable can be viewed through the shortcut key Shift + Z :

As you can see, three variables are output in the figure above, and now we want to use a variable named token , then we can fill in the parameter column in the form of ${variable name} , and the filled value is: ${token} , Examples are as follows:

Of course, variables support splicing with ordinary strings, like this: ${token} 123

Multivariate and nested variables are also supported:

  1. Multivariate: ${token}${name}

  1. Nested variables: ${${name}}


But in actual use, variables are often an array (list) or dictionary, but we only want to use a certain element value in it instead of the entire piece of data.

Lim also has good support for this case:

  1. The variable is an array, and we only want to take one of the elements: In this case, we can directly input it in the form of ${variable[subscript value]}, of course, the subscript value is also supported: ${variable1[ ${variable 2}]} If you use a loop controller, you can use the number of cycles as the subscript value. Lim defaults i as the subscript value of the number of cycles: ${variable[i]}

  1. The variable is a multi-layer dictionary, and we want to take the value of a certain layer: For example, there is a variable named dict_var, and its value is as follows:

{
  "name": "曲鸟",
  "level1": {
    "level2": [
      1,
      2,
      3
    ]
  }
}

我们现在想取其中的 level1 ,那可以这样写 ${dict_var.level1}

因为平台有参数自动识别的功能,会将上面取值转化为字符串,所以我们需要手动将字段类型改为object 并关闭类型自动识别即可:


这样我们就能拿到我们想要的格式的值了。

同理,以上面的 dict_var 变量为例,我们想取 level2 中的第一个值,那我们可以这样写:${dict_var.level1.level2[0]}

但有时候实际的情况更为复杂,我们想对变量进行切片、计算等操作后再输出,这类操作使用代码是更为方便的,所以Lim也支持 eval 操作,比如我们想对 level2 进行切片(去除第一个元素)后再取它的长度,那么我们可以这样写: eval(len(${dict_var.level1.level2}[1:]))

另外,我们还可以使用代码模式来实现它,甚至是更为复杂的情况,需要依赖包的情况也都能通过代码模式解决:

Lim测试平台的变量使用先讲解到这里,后续还会将所有功能模块一一讲解。

另外,在未来的版本还会加入测试报告、Swagger导入、自定义函数以及执行实时监控等功能。大家提出的问题和BUG也会尽量解决。让我们一起成长吧!

大家可随时关注项目仓库获取最新消息:

Gitee(国内镜像)

Github

Guess you like

Origin blog.csdn.net/momoda118/article/details/130485438