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

查看:412
本文介绍了自动增加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}"
  }
}

检查唯一的用户名:

Check for unique username:

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


推荐答案

请记住,内部SoapUI保持XML格式的所有内容,因此所有属性都只是字符串。此外,每个Groovy Script步骤都会被实例化为一个新的类,因此它不能记住以前的任何状态。

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天全站免登陆