Forum Discussion
morciani
15 years agoOccasional Contributor
Hello,,
Me again....I've found this post to be useful:
http://www.eviware.com/forums/index.php?topic=1304.0
I am getting closer. I used this methodology to "auto create" my target TestSuite and TestCase- I added the code to the Setup Script withn my data driven Test Case. My soapUI project now looks like this:
Project
TestSuite_DataDriven
TestCase_DataDriven_Scenario1
TestCase_DataDriven_Scenario2
TestCase_DataDriven_Scenario3
TestSuite_Target_2010-04-19 (created by my setup script in TestCase_DataDriven_Scenario1 above)
TestCase_Target_2010-04-19_15.09.11 (created by my setup script in TestCase_DataDriven_Scenario1 above)
I have the following code within a script assertion (TestRequest) inside of 'TestCase_DataDriven_Scenario1':
________________
//If we do indeed want to create a TestSuite, TestCase, and the individual TestSteps (requests), proceed
if ( context.expand( '${#Project#TestSuiteName_ToCreate}' ) != "" ) {
//Gather all the information we'll need to create the request
def date = new Date()
def dateFormat = new java.text.SimpleDateFormat("yyyy-MM-dd_HH.mm.ss")
def shortDate2 = dateFormat.format(date)
def name = context.expand( '${DataGen#CompanysQuoteNumber}' )
def testStepName = name + "_Request1_TPPR_Rq_" + shortDate2;
def interfaceName = context.expand( '${#Project#InterfaceName}' );
def operationName = context.expand( '${#Project#OperationName_TPPR}' );
def targetTestSuite = context.expand( '${Properties#TestSuiteName_AssignedByScript}' );
def targetTestCase = context.expand( '${Properties#TestCaseName_AssignedByScript}' );
def request = context.expand( '${TestRequest_TPPR#Request}' )
def response = context.expand( '${TestRequest_TPPR#Response}' )
// Get the WSDL operation name
def op = testRunner.testCase.testSuite.project.interfaces[interfaceName].operations[operationName];
//Gather what we'll need to create the request
def config = com.eviware.soapui.impl.wsdl.teststeps.registry.WsdlTestRequestStepFactory.createConfig( op, testStepName );
//Add a new TestStep to the TestCase
def newTestStep = testRunner.testCase.testSuite.project.testSuites["TestSuite_2010_04-19"].testCases["TestCase_2010-04-19_15.09.11"].addTestStep ( config );
//set the request & response for the new TestStep
newTestStep.setPropertyValue("request", "request");
newTestStep.setPropertyValue("response", "response");
// read and log the request
def testStepRequest = newTestStep.getPropertyValue("request");
log.info(testStepRequest);
}
_________
No luck just yet. Perhaps someone could provide an example of how to create a TestRequest type TestStep using a script assertion?
Me again....I've found this post to be useful:
http://www.eviware.com/forums/index.php?topic=1304.0
I am getting closer. I used this methodology to "auto create" my target TestSuite and TestCase- I added the code to the Setup Script withn my data driven Test Case. My soapUI project now looks like this:
Project
TestSuite_DataDriven
TestCase_DataDriven_Scenario1
TestCase_DataDriven_Scenario2
TestCase_DataDriven_Scenario3
TestSuite_Target_2010-04-19 (created by my setup script in TestCase_DataDriven_Scenario1 above)
TestCase_Target_2010-04-19_15.09.11 (created by my setup script in TestCase_DataDriven_Scenario1 above)
I have the following code within a script assertion (TestRequest) inside of 'TestCase_DataDriven_Scenario1':
________________
//If we do indeed want to create a TestSuite, TestCase, and the individual TestSteps (requests), proceed
if ( context.expand( '${#Project#TestSuiteName_ToCreate}' ) != "" ) {
//Gather all the information we'll need to create the request
def date = new Date()
def dateFormat = new java.text.SimpleDateFormat("yyyy-MM-dd_HH.mm.ss")
def shortDate2 = dateFormat.format(date)
def name = context.expand( '${DataGen#CompanysQuoteNumber}' )
def testStepName = name + "_Request1_TPPR_Rq_" + shortDate2;
def interfaceName = context.expand( '${#Project#InterfaceName}' );
def operationName = context.expand( '${#Project#OperationName_TPPR}' );
def targetTestSuite = context.expand( '${Properties#TestSuiteName_AssignedByScript}' );
def targetTestCase = context.expand( '${Properties#TestCaseName_AssignedByScript}' );
def request = context.expand( '${TestRequest_TPPR#Request}' )
def response = context.expand( '${TestRequest_TPPR#Response}' )
// Get the WSDL operation name
def op = testRunner.testCase.testSuite.project.interfaces[interfaceName].operations[operationName];
//Gather what we'll need to create the request
def config = com.eviware.soapui.impl.wsdl.teststeps.registry.WsdlTestRequestStepFactory.createConfig( op, testStepName );
//Add a new TestStep to the TestCase
def newTestStep = testRunner.testCase.testSuite.project.testSuites["TestSuite_2010_04-19"].testCases["TestCase_2010-04-19_15.09.11"].addTestStep ( config );
//set the request & response for the new TestStep
newTestStep.setPropertyValue("request", "request");
newTestStep.setPropertyValue("response", "response");
// read and log the request
def testStepRequest = newTestStep.getPropertyValue("request");
log.info(testStepRequest);
}
_________
No luck just yet. Perhaps someone could provide an example of how to create a TestRequest type TestStep using a script assertion?
Related Content
- 5 years agopmagr
- 10 years agodmohapl
- 4 years agoLeela1
- 6 years agonimishbhuta
Recent Discussions
- 6 days agoemoya