Thursday, 3 May 2012

Functional Testing and Loop Request

To archive such needs use test soapUI capabilities.

In that project there’s included a test case that can be configured to insert n users defined in a properties file.

The script will then create n user joining n to user id (i.e. j.doe23).

To be able to execute this step perform  the following steps:

1.       Edit service endpoint
2.       Expand testsuite existant inside testcase SoapUI project
3.       Expand Test Steps
4.       Double-Click CreateUserProperties
5.       Change the properties according to your needs and saves to the selected properties target file
6.       Double-clicktest-case
7.       Select Run this Test Case (Green play button on left top corner of click test-case)

NOTE: To implement WSSecurity Header on request please change CreateUserRequest test step on test-case.

Groovy code snipped to perform a loop request

// run ten random requests"In the BC2 Create User Setup Script")

def userIdInStep = testRunner.testCase.getTestStepByName( "CreateUserProperties" )
def firstName = userIdInStep.getPropertyValue( "FirstName" )
def lastName = userIdInStep.getPropertyValue( "LastName" )
def userId = userIdInStep.getPropertyValue( "userId" )
def nTests = userIdInStep.getPropertyValue( "UsersToCreate" )"Number total of tests: " + nTests)"Company Mkey: " + nTests)"Company Address MKey: " + nTests)

def groovyUtils = new

for( i in 1..nTests.toInteger())
  def holder = groovyUtils.getXmlHolder( "CreateUserRequest#Request" )
  holder.setNodeValue( "//urn:userId", userId + i)
  holder.setNodeValue( "//urn:lastName", lastName + i)
  node = holder.getNodeValue("//urn:userId") ("Created user: " + node)
  node = holder.getNodeValue("//urn:lastName") ("Created user last name: " + node)

To use properties directely on request xml


No comments:

Post a Comment