Forum Discussion
- TNeuschwangerChampion Level 1
Hello deanding
You will have to do some coding I think...
I assume (your question leads to a lot of assumptions) what you are showing is txt file from testrunner.bat execution... What your img shows is the result of a test step not a test case...
Those txt files are produced from every test step executed. You will need to add a 'TestRunListener.afterStep' event listener for the project (right click on your project name | choose 'Events' from the available menu items). I have some sandbox code below for that event (I found a little bit of the code searching this Smartbear site). You can hack it up as needed. I have added a couple lines for a 'jdbc' step type at the end of this sample, but I have not tested it. It may lead you to an ultimate solution by researching events further however. ๐
import com.eviware.soapui.impl.wsdl.teststeps.WsdlTestRequestStep import com.eviware.soapui.impl.wsdl.teststeps.RestTestRequestStep import com.eviware.soapui.impl.wsdl.teststeps.HttpTestRequestStep import static com.eviware.soapui.model.testsuite.TestStepResult.TestStepStatus.* import static com.eviware.soapui.impl.wsdl.submit.transports.http.BaseHttpRequestTransport.HTTP_METHOD // ////Closure to get ExtendedHttpMethod object //def eHM = { context.getProperty(HTTP_METHOD) } // ////Initialize report //def message = new StringBuilder() // ////Add the test properties to report similar to failure case as this helps to understand easily if something is missing or incorrect //def addPropertiesToReport = { // message.with { // append('\n----------------- Properties -----------------\n') // append("Endpoint: ${context.endpoint}\n") // switch (context.currentStep) { // case WsdlTestRequestStep: // append("Encoding: ${context.currentStep.testRequest.encoding}\n") // append(" --- TESTING WsdlTestRequestStep \n") // break // default: // append("HTTP Version: ${eHM().protocolVersion}\n") // append("Method: ${eHM().method}\n") // append("StatusCode: ${testStepResult.getProperty('StatusCode')}\n") // append("URL: ${eHM().URL}\n") // append(" --- TESTING Default \n") // break // } // } //} // //def addPayLoadToReport = { subHead, content, additionalData = null -> // message.with { // append("\n-------------- $subHead --------------\n") // if(additionalData) { // append(eHM().requestLine).append('\n') // additionalData.each { append(it.name + ' : ' + it.value + '\n')} // } // if (content) { append('\n').append(content).append('\n') } // } //} // ////Actual business logic //if (([WsdlTestRequestStep, RestTestRequestStep, HttpTestRequestStep].any{context.currentStep in it}) && (testStepResult.status in [UNKNOWN, OK, PASS])) { // addPropertiesToReport() // addPayLoadToReport('Request', eHM().entity?.content?.text, eHM().allHeaders) // addPayLoadToReport('Response', context.rawResponse) // testStepResult.addMessage(message.toString()) //} // Get the test step's results, PASS or FAIL def testStatus = testStepResult.getStatus(); // Get a reference to the test step def testStep = testStepResult.getTestStep(); // Get the test type def tsType = testStep.config.type.toString() // httprequest // groovy // properties // jdbc //// Skip steps that are not soap or rest //if (tsType.equals("soaprequest") || tsType.equals("restrequest")) //{ // // Skip tests that are not PASS // if (testStatus.toString().equals("PASS")) // { // // Build full URL // def endPoint = testStep.getHttpRequest().getEndpoint(); // def URI = testStepResult.getTestStep().getHttpRequest().getPath() // def path = "$endPoint/$URI"; // // def response = testStep.getPropertyValue("RawResponse"); // // // Add the URL and raw response to the test step result messages, which flows to the test report. // testStepResult.addMessage("Request URL: $path"); // testStepResult.addMessage("Raw Response: $response"); // } //} if (tsType.equals("httprequest")) { def environmentName = testRunner.testCase.project.getActiveEnvironment().name; testStepResult.addMessage(" "); testStepResult.addMessage("EnvironmentName = $environmentName" ); }; if (tsType.equals("properties")) { testStepResult.addMessage(" "); testStepResult.addMessage("First 25 char of Name... First 100 char of Value..."); testStepResult.addMessage("_________________________ ___________________________________________________________________________________________________"); //testStepResult.addMessage("Name ------------------- Value -------------------------------------------"); for( prop in testStep.propertyNames ) { //log.info( prop + "=" + testStep.properties[prop].value ); // webHostUnderTestBrowserFlavor = webHostUnderTestBrowserFlavor ?: 'chrome'; // if environment variable is not set, default to chrome... name = prop ?: ''; val = testStep.properties[prop].value ?: ''; testStepResult.addMessage("${name.take(25).padRight(25,' ')} ${val.take(100)}" ); }; }; //testStepResult.addMessage(" --- TESTING"); //testStepResult.addMessage(" -- ${testStep.name}"); //testStepResult.addMessage(" -- $tsType"); if (tsType.equals("jdbc")) { environmentName = testRunner.testCase.project.getActiveEnvironment().name; testStepResult.addMessage(" "); testStepResult.addMessage("EnvironmentName = $environmentName" ); testStepResult.addMessage("**** More of your jdbc output needs are coded here ****" ); //. // **** More of your jdbc output needs are coded here **** //. };
Give it a try and see what happens.
Regards,
Todd
- richieCommunity HeroHey TNeuschwanger,
Thanks for that. I had the same problem about 5 years ago where i had an event handler script extracting the request/response stuff for my test evidence, but i never sorted it for my JDBC steps, so nice one for this! Definitely worth some kudos! ๐
Cheers,
Rich
Related Content
- 4 years ago
- 6 years ago
- 2 years ago
Recent Discussions
- 21 days ago