SOAPUI testSuite 的自增自定义属性 [英] Auto-increment Custom Properties for SOAPUI testSuite

查看:34
本文介绍了SOAPUI testSuite 的自增自定义属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望在 SOAPUI 测试运行时自动增加自定义属性.目前我的测试要求有一个独特的部分,称为 UniqueUserPortion,当我测试用户名/电子邮件的唯一性时,它会增加.有没有办法让我增加这个自定义属性(#Project#UniqueUserPortion),因为我需要它在下一步检查唯一用户名时是唯一的?检查唯一的电子邮件:

I am looking to auto-increment a Custom Property as my SOAPUI test is running. Currently my tests require that there be a unique portion, referred to as UniqueUserPortion, that get incremented as I test for uniqueness in usernames/emails. Is there a way for me to increment this custom property (#Project#UniqueUserPortion), as I will need it to be unique for the next step which is the check for unique username? Check for unique email:

    {  
  "UpdateIdentityRequest":{  
    "guid":"${#Project#UserGUID}",
    "emailAddress": "tomTestUser11@testit.com",
    "screenName": "UpdateUser${#Project#UniqueUserPortion}",
    "inputSystem":"${#Project#UserInputSystem}"
  }
}

检查唯一的用户名:

    {  
  "UpdateIdentityRequest":{  
    "guid":"${#Project#UserGUID}",
    "emailAddress": "UpdateUser${#Project#UniqueUserPortion}@test.com",
    "screenName": "testUser2011",
    "inputSystem":"${#Project#UserInputSystem}"
  }
}

推荐答案

请记住,SoapUI 在内部以 XML 格式保存所有内容,因此所有属性都只是字符串.此外,每个 Groovy 脚本步骤都被实例化为一个新类,因此它无法记住"任何以前的状态.

Remember that internally SoapUI keeps everything in XML, and so all properties are just strings. Further, every Groovy Script step get instantiated as a new class, so it cannot "remember" any previous state.

您必须执行以下操作:

// read the property as a string
def uniqueUserPortion = testRunner.testCase.testSuite.project.getPropertyValue("UniqueUserPortion")
// convert it to an Integer, and increment
def uniqueUserPortionInc = uniqueUserPortion.toInteger() + 1
// set the property back as string
testRunner.testCase.testSuite.project.setPropertyValue("UniqueUserPortion", uniqueUserPortionInc.toString())
// check
log.info testRunner.testCase.testSuite.project.getPropertyValue("UniqueUserPortion")

这篇关于SOAPUI testSuite 的自增自定义属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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