Auto-increment Custom Properties for SOAPUI testSuite

后端 未结 1 1261
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-21 08:45

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

相关标签:
1条回答
  • 2021-01-21 09:16

    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")
    
    0 讨论(0)
提交回复
热议问题