SOAPUI使用Groovy从文件加载定制属性 [英] SOAPUI Load Custom Properties from file using groovy

查看:169
本文介绍了SOAPUI使用Groovy从文件加载定制属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个普通脚本,该脚本使用属性文件中的信息加载测试套件的自定义属性. 该属性文件具有大约6个不同的属性 我看了很多不同的方法,即从Properties测试步骤加载并尝试使用groovy扩展属性,但是没有成功.

I am trying to write a groovy script which loads the custom properties for a test suite using information from a properties file. The properties file has around 6 different attributes I have had a look at quite a few different methods i.e Loading from Properties test step and trying to expand the properties with groovy, but have not been successful.

如果有人可以建议如何实现这一目标,将不胜感激.

If anyone could advise on how to achieve this, it would be much appreciated.

谢谢.

推荐答案

这是groovy脚本,可读取属性文件并将其设置为test suite level:

Here is the groovy script which reads a property file and set them at test suite level:

def props = new Properties()
//replace the path with your file name below. use / instead of \ as path separator even on windows platform.
new File("/absolute/path/of/test.properties").withInputStream { s ->
  props.load(s) 
}
props.each {
    context.testCase.testSuite.setPropertyValue(it.key, it.value)
}

上面的脚本对存在groovy脚本的当前套件进行了负载测试套件级别.

The above script load test suite level for the current suite where the groovy script is present.

这篇关于SOAPUI使用Groovy从文件加载定制属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆