Forum Discussion
tjdurden
12 years agoFrequent Contributor
Hi Suresh,
I've created something that you may find of use. In my project I have used just a single TestCase, with 3 TestSteps, in the following order:
1) A groovy step, called 'myGroovy'.
2) A properties file, called 'myProperties', which contains a single property, called 'myParam'
3) A test request, called 'myRequest', containing my SOAP request.
It also assumes you've got a parameters file (called 'params.txt') containing your 5-digit values.
Here's how to set it up:
The groovy step:
In the Groovy step, paste the following code:
The properties step:
The properties step should contain a single parameter, called 'myParam'. I set the initial value to 0.
The SOAP request
You can use whatever SOAP request you want, but make sure you use the parameter identifier, which will be ${myProperties#myParam}.
The groovy step will basically read in the external properties file, and store each line into an array. This array is then iterated in a loop and for each iteration it updates the myParam property, then executes the myRequest test step, using the updated parameter value. The loop will stop when all iterations have been completed.
I hope this goes some way to helping you out.
Kind regards,
Tim
I've created something that you may find of use. In my project I have used just a single TestCase, with 3 TestSteps, in the following order:
1) A groovy step, called 'myGroovy'.
2) A properties file, called 'myProperties', which contains a single property, called 'myParam'
3) A test request, called 'myRequest', containing my SOAP request.
It also assumes you've got a parameters file (called 'params.txt') containing your 5-digit values.
Here's how to set it up:
The groovy step:
In the Groovy step, paste the following code:
// Define a new array called 'paramList'
def paramList = [];
// Store each line of a specified text file as an item in the array
new File( "C:\\params.txt" ).eachLine { line -> paramList.add( line ) };
// Loop through each item in the array
for ( i in paramList ) {
def myProps = new java.util.Properties();
myProps = testRunner.testCase.getTestStepByName("myProperties");
// Replace existing myParam value with new item from array
myProps.setPropertyValue("myParam",i);
// Execute the myRequest TestStep
log.info("Sending request using param value: " + i);
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context );
def testCase = testRunner.testCase;
def testStep = testCase.getTestStepByName("myRequest");
// OR USE: def testStep = testCase.getTestStepAt(0);
// OR USE: def testStep = testCase.testSteps["Delay"];
testRunner = new com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner(testCase, null);
testStepContext = new com.eviware.soapui.impl.wsdl.testcase.WsdlTestRunContext(testStep);
testStep.run(testRunner, testStepContext);
}
The properties step:
The properties step should contain a single parameter, called 'myParam'. I set the initial value to 0.
The SOAP request
You can use whatever SOAP request you want, but make sure you use the parameter identifier, which will be ${myProperties#myParam}.
The groovy step will basically read in the external properties file, and store each line into an array. This array is then iterated in a loop and for each iteration it updates the myParam property, then executes the myRequest test step, using the updated parameter value. The loop will stop when all iterations have been completed.
I hope this goes some way to helping you out.
Kind regards,
Tim
Related Content
- 7 years ago
- 6 years ago
Recent Discussions
- 3 days ago