Compare Json Response from the data source with the actual response in event
In my correct setup I have scenarios where I need to compare the JSON response from the data source to actual response, this can be done in a separate groovy but because of implementation structure we want to compare it in RequestFilter.afterRequest even. The problem we are running into is in event we are not able to fetch expected response from datasource, can someone please have a look into this and suggest how this can be achived.Solved3.8KViews0likes14CommentsSoapUI Jenkins: how to use TestSuiteRunListener
Hi, I have a test pipeline running in Jenkins with a SoapUI node connected to it. I want to run a script (in a test suite, in a testcase) ONE time before I start running my testsuite (I have only one for now). I thought about using the Event TestRunListener.beforeRun, but that will run the script everytime a test case starts.Then I thought about using the TestSuiteRunListener.beforeRun. But that one gave the following exception: 08:59:45 08:59:45,811 ERROR [EventHandlersRequestFilter] com.eviware.soapui.support.scripting.ScriptException: Error in TestSuiteRunListener.beforeRun 08:59:45 08:59:45,817 ERROR [SoapUI] An error occurred [Error in TestSuiteRunListener.beforeRun], see error log for details 08:59:45 08:59:45,818 ERROR [errorlog] com.eviware.soapui.support.scripting.ScriptException: Error in TestSuiteRunListener.beforeRun 08:59:45 com.eviware.soapui.support.scripting.ScriptException: Error in TestSuiteRunListener.beforeRun 08:59:45 Caused by: groovy.lang.MissingPropertyException: No such property: testCase for class: com.eviware.soapui.impl.wsdl.testcase.WsdlTestSuiteRunner Apparently there is something wrong with the following code that I use: // Check if the test case is run from the command line if (com.eviware.soapui.SoapUI.isCommandLine()) { log.info "This code is executed by Command Line SoapUI" log.info "Now running setup scripts" def testCase = testRunner.testCase.testSuite.project.testSuites['testsuite'].testCases['testcase'] def testStep = testCase.getTestStepByName("teststep") testStep.run( testRunner, context ) } It doesn't recognize testCase for class: com.eviware.soapui.impl.wsdl.testcase.WsdlTestSuiteRunner used here: def testCase = testRunner.testCase.testSuite.project.testSuites['testsuite'].testCases['testcase'] So how do I script to have the testRunner run the testcase'Setup Project' in the testsuite 'tooling-general' using theestSuiteRunListener.beforeRun?Solved2.3KViews0likes3Commentsadd request header to all calls
I am trying to find a better solution for adding a header to all calls. This questions was already asked here and earlier here. The proposed solution for both of these was to add a RequestFilter.filterRequest event: def headers = request.requestHeaders headers.put( "X-test", "test" ) request.requestHeaders = headers This solution has two problems: This just keeps adding the same header for each call; meaning if you make the call say three times, you have three of these headers. I tried adding a RequestFilter.afterRequest event with request.requestHeaders.clear() , but that did not work. I have multiple services in my project, and I need to add this header for all requests of only one of my services. Any advice would be appreciated.Solved4.3KViews0likes7CommentsReplace request content using RequestFilter.filterRequest does not work
I want to send urlencoded request, to achive that I am using following code in RequestFilter.filterRequest def requestHeaders = request.getRequestHeaders() def contentType = requestHeaders.get("Content-Type")[0].trim().toLowerCase() def reqContent = context.requestContent if (contentType=="application/x-www-form-urlencoded" && reqContent){ reqContent = java.net.URLEncoder.encode(reqContent.replaceAll('\t', ' ').replaceAll('\r\n|\n', ''), java.nio.charset.StandardCharsets.UTF_8.toString()) context.requestContent = "=$reqContent".toString() } But It doesn't send URLEncoded request. According to http://blog.smartbear.com/soapui/soapui-pro-holiday-goodies-event-handlers-and-jdbc-connections/ article, it should work. Am I missing something? I don't want to use SubmitListener.beforeSubmit event with request.setRequestContent as It changes request content in the test and next time it becomes unreadable for anyone. Any Suggestion folks? Thanks, Ritesh3.9KViews0likes9Commentscreate issue in jira using API using event handler when Testcase get Failed
I want to create issue in Jira with JIRA API using Event handler in SOAP UI. I want to Run JIRA API to create issue in JIRA after the Test Case get failed. I have tried but i am failed how to get status/result of Test Case. So please help me achieve this. Event Handler TestSuiteRunListener.afterTestCase if (Test case status = Failed) Run Jira Rest Api Request step to create issue1.1KViews0likes1Comment