Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
805 views
in Technique[技术] by (71.8m points)

testing - Auto-increment Custom Properties for SOAPUI testSuite

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": "[email protected]",
    "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}"
  }
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.

You will have to do something like:

// 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")

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...