Contributions
creating Test Requests with Groovy
I am having an issue dynamically creating test requests via Groovy script I have used the forums to come up with a few simple lines of code: ______ import com.eviware.soapui.impl.wsdl.teststeps.registry.WsdlTestRequestStepFactory // get request def iface = testRunner.testCase.testSuite.project.getInterfaceByName( "PmThirdPartyRateExportIHomePolicyQuoteHttpBinding" ); def request = iface.getOperationByName( "CreateHomePolicyQuote" ).getRequestByName( "Request 1" ) // create config and add teststep def config = WsdlTestRequestStepFactory.createConfig( request, "TestRequest_CreateHomePolicyQuote" ) def testStep = testRunner.testCase.insertTestStep( config, -1 ) ________ When I attempt to run this, I get the following in the 'error log': Thu Apr 22 11:52:01 EDT 2010:ERROR:java.lang.NullPointerException: Cannot invoke method getOperationByName() on null object java.lang.NullPointerException: Cannot invoke method getOperationByName() on null object at org.codehaus.groovy.runtime.NullObject.invokeMethod(NullObject.java:77) at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:45) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40) at org.codehaus.groovy.runtime.callsite.NullCallSite.call(NullCallSite.java:17) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40) at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:54) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125) at Script27.run(Script27.groovy:6) at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:93) at com.eviware.soapui.support.scripting.groovy.SoapUIProGroovyScriptEngineFactory$SoapUIProGroovyScriptEngine.run(SourceFile:51) at com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep.run(WsdlGroovyScriptTestStep.java:148) at com.eviware.soapui.impl.wsdl.panels.teststeps.GroovyScriptStepDesktopPanel$RunAction$1.run(GroovyScriptStepDesktopPanel.java:274) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Please let me know if I can provide any additional detail. Any help is appreciated!!!!!1KViews0likes0CommentsRe: programatically inserting Test Requests into an existing Test Case
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?854Views0likes0Commentsprogramatically inserting Test Requests into an existing Test Case
Hello, I have developed a suite of data driven test cases in soapUI that are working very nicely. I'm able to push large volumes of requests to my service, and monitor the results to be sure things are behaving as expected. On any given day, I may push through 15,000 service requests, and maybe for 14,950 of them, the expected response is returned. There are maybe 50 or so that do not result in the expected response. This is fine, and there is most likely a business reason for why the response has changed. Here is what I would like to be able to do: 1. Create a 'target' soapUI Test case, say 'TestCase_Target_UnexpectedResults_04-19-2010' that is empty / has no Test Steps. This Test Case would be within the same TestSuite as my data driven test case. (I would create this test case manually) 2. Run my data driven Test Case, say 'TestCase_DataDriven' (this Test case references 3 operations within 1 WSDL). As responses are returned, I would like to programatically insert Test Request Test Steps into the 'TestCase_Target_UnexpectedResults_04-19-2010' Test Case that I created in Step 1, for the 50 or so responses that did not contain the expected results. Basically, I would like to programatically insert Test Requests into an existing Test Case that contains these 50 or so troublesome requests from Step 2. The idea is that I can pass off this 'TestCase_Target_UnexpectedResults_04-19-2010' test case to another person who will investigate the reasons for the unexpected / failed results. I don't want the person to whom I am passing these requests to have to mess around with my data driven tests or anything like that- I just want to be able to quickly provide them with a list of requests that they can submit to the service individually as they troubleshoot. Note: I do have the code below that works nicely. This dumps out each request + response from my data driven test case to an external directory. Essentially, I would like to do something very similar. The only difference is that I want to dump the requests into a Test Case that I've already created. Code snippet: //Ouput the request and response to a local folder (${Properties#Location} def name = context.expand( '${DataGen#CompanysQuoteNumber}' ) def location = context.expand( '${#TestCase#Location}' ) def getResponseFilename(name) { date = new Date() dateFormat = new java.text.SimpleDateFormat("yyyy-MM-dd_HH.mm.ss") shortDate = dateFormat.format(date) respFilename = name + "_Request1_TPPR_Rs_" + shortDate + ".xml" } def getRequestFilename(name) { reqFilename = name + "_Request1_TPPR_Rq_" + shortDate + ".xml" } def file = new PrintWriter (location + getResponseFilename(name)) //def Response = testRunner.testCase.testSteps["TestRequest_TPPR"].testRequest.response.contentAsString def Response = context.expand( '${TestRequest_TPPR#Response}' ) file.println(Response) file.flush() file.close() def file2 = new PrintWriter (location + getRequestFilename(name)) def Request = context.expand( '${TestRequest_TPPR#Request}' ) file2.println(Request) file2.flush() file2.close()2.4KViews0likes2CommentsRe: data driven Test Case - saving requests / responses to an external folder
Excellent!!!! Thank you!!! I REALLY appreciate the time you devoted to this. I had something similar, but I didn't have the file.flush() or file.close() references. This works great. the final version looks like this: //Output the request and response to a local directory def name = context.expand( '${DataGen#CompanysQuoteNumber}' ) def location = context.expand( '${Properties#Location}' ) def getResponseFilename(name) { date = new Date() dateFormat = new java.text.SimpleDateFormat("yyyy-MM-dd_HH.mm.ss") shortDate = dateFormat.format(date) respFilename = name + "_Rs_" + shortDate + ".xml" } def getRequestFilename(name) { reqFilename = name + "_Rq_" + shortDate + ".xml" } def file = new PrintWriter (location + getResponseFilename(name)) def Response = testRunner.testCase.testSteps["TestRequest_TPPR"].testRequest.response.contentAsString file.println(Response) file.flush() file.close() def file2 = new PrintWriter (location + getRequestFilename(name)) def Request = context.expand( '${TestRequest_TPPR#Request}' ) file2.println(Request) file2.flush() file2.close()2.6KViews0likes0Commentsdata driven Test Case - saving requests / responses to an external folder
Hi All, I've built a data driven test case that works nicely. It looks like this: Test Case1 1. Properties (global data) 2. DataSource (request specific data from an Excel sheet) 3. DataGen (some data that needs to be calculated on the fly) 4. TestRequest (with a handful of assertions) 5. Groovy Script (logs results and transfers some properties from the response to the following step) 6. Properties_Response (holds properties from the latest response) 7. DataSource Loop (keeps submitting requests until it runs out of data) Pretty standard, and it works well, but I'd like it to do a bit more. I would like to be able to collect the actual requests sent and responses received in an external location ('c:/soapUI_requests_responses' for example). Take this example: My Excel sheet in Step 2 contains the following 3 requests (rows): 01_AK_001 02_AL_001 03_AR_001 If run with this data, my Test Case will iterate 3 times. I would like a way to save the requests / responses externally, so that 'c:/soapUI_requests_responses' contains the actual requests / responses passed to the service, like this: 01_AK_001_Request.xml 01_AK_001_Response.xml 02_AL_001_Request.xml 02_AL_001_Response.xml 03_AR_001_Request.xml 03_AR_001_Response.xml Any ideas on some Groovy scripting (or other means) that would accomplish this? Thanks in advance for any help! -Mike4.9KViews0likes7CommentsRe: soapUI Pro memory / performance issue - newly created requests from new WSDL
Hi Ole, Thank you! This is indeed an issue with opening requests in the 'Form' view of the editor. I changed the setting: File--> Preferences--> soapUI Pro tab--> changed 'Default Request Editor' and 'Default Response Editor' to 'Source' Now I'm able to work with requests for the new WSDL. Attached is the WSDL / schema (dumped from soapUI Pro via the 'Export Definition' option, in case you want to take a look or try and replicate this issue. Thanks! -Mike537Views0likes0CommentssoapUI Pro memory / performance issue - newly created requests from new WSDL
Hello- I am experiencing a problem with soapUI Pro 3.5. Here are the steps to recreate my issue: 1. File--> New soapUI Project--> import the new WSDL (from the URL, not the WSDL file itself, Create Sample Requests for all Operations is checked) 2. The new WSDL imports successfully (I see the two operations and a request for each, as expected) 3. Attempt to open / view one of these requests- soapUI Pro 3.5 hangs, CPU goes to 100%, available memory drops to almost nothing... the whole application melts down! I do have a project that references the first version of my WSDL (with only one operation). I can open requests and generally work with the WSDL without any issues using soapUI Pro 3.5. I have tried Steps 1-3 above with soapUI 3.5 (non Pro version)- I DO NOT experience the issues described- both projects / WSDLs behave as expected. I've tried Steps 1-3 with soapUI Pro 3.0.2 and soapUI Pro 3.0.1. I DO experience the issue with these versions. From my perspective, there appears to be an issue in soapUI Pro (at least in the versions mentioned above) when I attempt to open / view requests that are associated with the new WSDL. I am successful in creating / opening / viewing requests created from this exact same WSDL using soapUI 3.5 and other tools (Altova XML Spy). Any advice / input in solving this problem is appreciated! Please let me know if I can provide any additional information. Also, is there a forum / means of getting support specifically for soapUI Pro? (I am using a paid license). -Mike1.4KViews0likes2CommentsRe: How to store response values into excel using SOAP UI pro?
I am doing something very similar. with soapUI Pro. I'm using a DataSource (Excel) that has some data elements that are used in submitting requests AND the expected results for responses. I've got the following steps in my test case: 1. DataSource 2. Test Request (with Assertions that reference columns in DataSource) 3. DataSource Loop (points to 'Test Request') If you wanted to save bits of data included in the responses into the same Excel sheet, you could add a DataSink step that references the same Excel sheet in the DataSource like this: 1. DataSource 2. Test Request (with Assertions that reference columns in DataSource) 3. DataSink (Excel, reference the same sheet in the DataSource step) 4. DataSource Loop (points to 'Test Request') This should get you on your way. -Mike4.6KViews0likes0CommentsRe: Referencing properties inside a DataGen Test Step
I figured this one out, context.expand('${#PropertyName}') is the syntax I was looking for. import javax.swing.* def SignOnRoleCd = context.expand( '${#SignOnRoleCd}' ) if (SignOnRoleCd == "Customer") { String PIN = "N0000000" } else { String PIN=JOptionPane.showInputDialog("PIN"); }437Views0likes0CommentsReferencing properties inside a DataGen Test Step
Hello, Is there a way to reference properties from within a DataGen Test step? I want to be able to conditionally set the value of a second property based on the value of the first property. Both properties are contained in the same DataGen step (DataGen_getGlobalData) Take this example of this Test Step: Test Step Name: DataGen_getGlobalData Property1: SignOnRoleCd (Type = Script, Mode = STEP, not Shared) Configuration: import javax.swing.* String SignOnRoleCd=JOptionPane.showInputDialog("SignOnRoleCd: Agent or Customer"); Property2: PIN ((Type = Script, Mode = STEP, not Shared) Configuration: if (#SignOnRoleCd == "Customer") { String PIN = "N0000000" } else { String PIN=JOptionPane.showInputDialog("PIN"); } How do I reference SignOnRoleCd within the configuration of Property2?919Views0likes1Comment