Wednesday, August 4, 2010

soapUI - parametrized tests

my goal was parametrized load tests - because of the data validation done by the web service it is not possible to run the same tests over and over again

some web sites

http://stackoverflow.com/questions/945403/soapui-getting-request-parameters-in-mock-service-script

http://www.soapui.org/Functional-Testing/working-with-scripts.html

http://groovyinsoapui.wordpress.com/2008/09/30/load-testing-with-soap-request-having-variable-parameters/

http://soa.dzone.com/articles/functional-web-services-1?page=0,5

was I accomplish was not much but:

1. TestSuite -> Test Case -> new Test Step 'Properties' - moved to the first place
defined new parameters:

receiptDateStr date e.g. 2010-08-04
receiptNumber numer e.g. 1

2. TestSuite -> Test Case -> Test Case Editor -> Setup Script added script that initialize the properties values:


log.info("In the Test Case IssueCheque Setup Script")
today = new Date()
sdf = new java.text.SimpleDateFormat("yyyy-MM-dd")
receiptDate = sdf.format(today)
log.info("In the Test Test Case IssueCheque Setup Script: receiptDate = " + receiptDate)

targetStep = testRunner.testCase.getTestStepByName( "Properties" )
// transfer all properties
targetStep.setPropertyValue( "receiptDateStr", receiptDate)

receiptNumber = Integer.valueOf(targetStep.getPropertyValue("receiptNumber"))
log.info("In the Test Test Case IssueCheque Setup Script: last receiptNumber = " + receiptNumber)
receiptNumber = receiptNumber + 1
log.info("In the Test Test Case IssueCheque Setup Script: current receiptNumber = " + receiptNumber)
targetStep.setPropertyValue( "receiptNumber", String.valueOf(receiptNumber))

log.info(receiptDate)

3. In the test case IssueCheque that follows Properties I replaced actual values with parameters referecences:

${Properties#receiptNumber}
${Properties#receiptDateStr}

No comments:

Post a Comment