soapui - SOAPUI 如何在属性转移目标中将值增加 1?
问题描述
有两个测试步骤并尝试从一个测试步骤获取属性值到另一个测试步骤并将其增加 1。转移不是问题,但如何将其增加 1?
解决方案
如果上面的代码确实是一个 Groovy 测试步骤,那么问题就出在第 1 行。您的代码看起来需要来自名为“Property Transfer”的测试步骤的 IncrementValue 值,但您的文本显示您已将自定义属性添加到测试案例,名称 IncrementValue。
要从测试用例客户属性中“提取”一个值,您需要执行此操作...
def incrementValue = context.expand( '${#TestCase#IncrementValue}' );
或者
def incrementValue = testRunner.testCase.getPropertyValue("IncrementValue");
您得到的错误是因为您试图将整数写入字符串属性。将整数转换为字符串,它将起作用。
看例子...
def incrementValue = testRunner.testCase.getPropertyValue("IncrementValue");
incrementValue = incrementValue.toInteger() + 1;
if (incrementValue <= 10) {
// Prop name AND value are strings...
testRunner.testCase.setPropertyValue("IncrementValue", incrementValue.toString());
}
log.info(incrementValue);
推荐阅读
- datalog - 如何实现一个基本的 Datalog 解释器?
- jquery - Symfony Form FileType 通过 AJAX:验证错误 isSubmitted() 总是 false with processData: false
- r - 扫描错误(file = file,what = what,sep = sep,quote = quote,dec = dec,:第 52 行没有 6 个元素
- php - 如何在循环外使用 array_push() 存储数组?
- video - 视频正在下载但未在浏览器中播放
- php - Laravel 按最后一条消息对对话进行排序
- r - 在 travis 上的 R 容器上安装特定节点版本
- java - Java Comparator 不比较每个对象
- python - 使用 numpy 将带有标题的列表列表转换为 csv
- scala - 如何在 Spark JDBC 中设置客户端信息,就像在 Connection setClientInfo 中一样