cancel
Showing results for 
Search instead for 
Did you mean: 

sorting properties

Highlighted
Occasional Contributor

sorting properties

Hi,
in soapui open source there is button for sorting properties (alphabetically).

Can anyone share how to get the same behaviour via groovy script? I want to sort all the properties used in given test case (properties defined on test case level)
alphabetically. The properties are in eg in transfers so I assume I can not just get properties map, sort it, delete all properties, and set them back from sorted
map. This way all the transfers will be nulled...

Yuor quick response is higlhy appreciated.
3 REPLIES 3
Highlighted
Occasional Contributor

Hi anybody can help?
Highlighted
Super Contributor

From within a Groovy script step in the test case:

def propList = []     
testRunner.testCase.getPropertyList().each { prop ->
pmap.add(prop.name)
}
def sortedList = propList.sort()
def index = 0
sortedList.each { name ->
testRunner.testCase.moveProperty(name, index++)
}

From the project Load script to sort properties in all test cases in all test suites:

project.testSuiteList.each { testSuite ->
testSuite.testCaseList.each { testCase ->
def propList = []
testCase.getPropertyList().each { prop ->
propList.add(prop.name)
}
def sortedList = propList.sort()
def index = 0
sortedList.each { name ->
testCase.moveProperty(name, index++)
}
}
}

I'm curious as to why you would want to do this.
"Ignorance more frequently begets confidence than does knowledge"
Highlighted
Occasional Contributor

M McDonald, thanks a lot!!!
How could I be so blind to miss the moveProperty method in the documentation
New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors