Contributions
How to save log.info/error/warning from groovy test step
Hi, I have big groovy script usable in both SoapUI Free and SoapUI pro. i have there lots of Log Outgoing how to save them by groovy script? all logs i found and try some kudos have result like this: /***********************enum test*************/ import com.eviware.soapui.model.testsuite.Assertable.AssertionStatus // firsthly def ArrayList - enums // this enums is available for change if another enums will change, dont change another part of code List<String> country = new ArrayList<String> (["MK", "AD", "AE", "AF"]) //, "AG", "AI", "AL", "AM", "AO", "AQ", "AR", "AS", "AT", "AU", "AW", "AX", "AZ", "BA", "BB", "BD", "BE", "BF", "BG", "BH", "BI", "BJ", "BL", "BM", "BN", "BO", "BQ", "BR", "BS", "BT", "BV", "BW", "BY", "BZ", "CA", "CC", "CD", "CF", "CG", "CI", "CK", "CL", "CM", "CN", "CO", "CR", "CU", "CV", "CW", "CX", "CY", "CZ", "DE", "DJ", "DK", "DM", "DO", "DZ", "EC", "EE", "EG", "EH", "ER", "ES", "ET", "FI", "FJ", "FK", "FM", "FO", "FR", "GA", "GB", "GD", "GE", "GF", "GG", "GH", "GI", "GL", "GM", "GN", "GP", "GQ", "GR", "GS", "GT", "GU", "GW", "GY", "HK", "HM", "HN", "HR", "HT", "HU", "CH", "ID", "IE", "IL", "IM", "IN", "IO", "IQ", "IR", "IS", "IT", "JE", "JM", "JO", "JP", "KE", "KG", "KH", "KI", "KM", "KN", "KP", "KR", "KW", "KY", "KZ", "LA", "LB", "LC", "LI", "LK", "LR", "LS", "LT", "LU", "LV", "LY", "MA", "MC", "MD", "ME", "MF", "MG", "MH", "ML", "MM", "MN", "MO", "MP", "MQ", "MR", "MS", "MT", "MU", "MV", "MW", "MX", "MY", "MZ", "NA", "NC", "NE", "NF", "NG", "NI", "NL", "NO", "NP", "NR", "NU", "NZ", "OM", "PA", "PE", "PF", "PG", "PH", "PK", "PL", "PM", "PN", "PR", "PS", "PT", "PW", "PY", "QA", "RE", "RO", "RS", "RU", "RW", "SA", "SB", "SC", "SD", "SE", "SG", "SH", "SI", "SJ", "SK", "SL", "SM", "SN", "SO", "SR", "SS", "ST", "SV", "SX", "SY", "SZ", "TC", "TD", "TF", "TG", "TH", "TJ", "TK", "TL", "TM", "TN", "TO", "TR", "TT", "TV", "TW", "TZ", "UA", "UG", "UM", "US", "UY", "UZ", "VA", "VC", "VE", "VG", "VI", "VN", "VU", "WF", "WS", "YE", "YT", "ZA", "ZM", "ZW"]) log.info "!!!!!!!Dont stop this Test Step!!!!!!!!!" log.info "!!!!!!!Dont change this Test Step when run!!!!!!!!!" log.info "!!!!!!!Wait for results at least 10 minutes!!!!!!!!!" //def actual test Case and Test STep def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context ); def testCase = testRunner.testCase; def testStep = testCase.getTestStepAt(context.currentStepIndex + 2); //set property country with value item into TestCase testRunner.testCase.setPropertyValue("country", country[0]) //log.info testStep + ": " + country[0] //now run test step (will be run by count of enum values) 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); // here we detect if test case were failed (when is not firsth if, then list all assertion test steps in test case, is usable as Tear Down Script too) def StepList = testCase.getTestStepList() if (country != country[0] && country[0] != null){ StepList.each{ if(it.metaClass.hasProperty(it,'assertionStatus')){ if(it.assertionStatus != AssertionStatus.FAILED){ log.error "${it.name} FAIL with value of: " + item return; } else if(it.assertionStatus == AssertionStatus.VALID){ log.info "${it.name} OK!" // now loop arrayList value by value it means item and run it in Test step MTD-ESB-TLM-Country-all (next 1th test step) for (String item : country) { //set property country with value item into TestCase testRunner.testCase.setPropertyValue("country", item) //log.info testStep + ": " + item //now run test step (will be run by count of enum values) 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); } } else if(it.assertionStatus == AssertionStatus.UNKNOWN){ log.info "${it.name} UNKNOWN (PROBABLY NOT ALREADY EXECUTED)" log.error "${it.name} FAIL with value of: " + item return; } } } } }/***********************enum test*************/ import com.eviware.soapui.model.testsuite.Assertable.AssertionStatus // firsthly def ArrayList - enums // this enums is available for change if another enums will change, dont change another part of code List<String> country = new ArrayList<String> (["MK", "AD", "AE", "AF"]) //, "AG", "AI", "AL", "AM", "AO", "AQ", "AR", "AS", "AT", "AU", "AW", "AX", "AZ", "BA", "BB", "BD", "BE", "BF", "BG", "BH", "BI", "BJ", "BL", "BM", "BN", "BO", "BQ", "BR", "BS", "BT", "BV", "BW", "BY", "BZ", "CA", "CC", "CD", "CF", "CG", "CI", "CK", "CL", "CM", "CN", "CO", "CR", "CU", "CV", "CW", "CX", "CY", "CZ", "DE", "DJ", "DK", "DM", "DO", "DZ", "EC", "EE", "EG", "EH", "ER", "ES", "ET", "FI", "FJ", "FK", "FM", "FO", "FR", "GA", "GB", "GD", "GE", "GF", "GG", "GH", "GI", "GL", "GM", "GN", "GP", "GQ", "GR", "GS", "GT", "GU", "GW", "GY", "HK", "HM", "HN", "HR", "HT", "HU", "CH", "ID", "IE", "IL", "IM", "IN", "IO", "IQ", "IR", "IS", "IT", "JE", "JM", "JO", "JP", "KE", "KG", "KH", "KI", "KM", "KN", "KP", "KR", "KW", "KY", "KZ", "LA", "LB", "LC", "LI", "LK", "LR", "LS", "LT", "LU", "LV", "LY", "MA", "MC", "MD", "ME", "MF", "MG", "MH", "ML", "MM", "MN", "MO", "MP", "MQ", "MR", "MS", "MT", "MU", "MV", "MW", "MX", "MY", "MZ", "NA", "NC", "NE", "NF", "NG", "NI", "NL", "NO", "NP", "NR", "NU", "NZ", "OM", "PA", "PE", "PF", "PG", "PH", "PK", "PL", "PM", "PN", "PR", "PS", "PT", "PW", "PY", "QA", "RE", "RO", "RS", "RU", "RW", "SA", "SB", "SC", "SD", "SE", "SG", "SH", "SI", "SJ", "SK", "SL", "SM", "SN", "SO", "SR", "SS", "ST", "SV", "SX", "SY", "SZ", "TC", "TD", "TF", "TG", "TH", "TJ", "TK", "TL", "TM", "TN", "TO", "TR", "TT", "TV", "TW", "TZ", "UA", "UG", "UM", "US", "UY", "UZ", "VA", "VC", "VE", "VG", "VI", "VN", "VU", "WF", "WS", "YE", "YT", "ZA", "ZM", "ZW"]) log.info "!!!!!!!Dont stop this Test Step!!!!!!!!!" log.info "!!!!!!!Dont change this Test Step when run!!!!!!!!!" log.info "!!!!!!!Wait for results at least 10 minutes!!!!!!!!!" //def actual test Case and Test STep def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context ); def testCase = testRunner.testCase; def testStep = testCase.getTestStepAt(context.currentStepIndex + 2); //set property country with value item into TestCase testRunner.testCase.setPropertyValue("country", country[0]) //log.info testStep + ": " + country[0] //now run test step (will be run by count of enum values) 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); // here we detect if test case were failed (when is not firsth if, then list all assertion test steps in test case, is usable as Tear Down Script too) def StepList = testCase.getTestStepList() if (country != country[0] && country[0] != null){ StepList.each{ if(it.metaClass.hasProperty(it,'assertionStatus')){ if(it.assertionStatus != AssertionStatus.FAILED){ log.error "${it.name} FAIL with value of: " + item return; } else if(it.assertionStatus == AssertionStatus.VALID){ log.info "${it.name} OK!" // now loop arrayList value by value it means item and run it in Test step MTD-ESB-TLM-Country-all (next 1th test step) for (String item : country) { //set property country with value item into TestCase testRunner.testCase.setPropertyValue("country", item) //log.info testStep + ": " + item //now run test step (will be run by count of enum values) 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); } } else if(it.assertionStatus == AssertionStatus.UNKNOWN){ log.info "${it.name} UNKNOWN (PROBABLY NOT ALREADY EXECUTED)" log.error "${it.name} FAIL with value of: " + item return; } } } } } It means: it log only part of code, but not log.info/error/warning... from Log Output with the values of variables - I may made it manualy, but I want execute all project from command line its general task from our DevOps. How to script it in both versions (not all testers here have full version) Thanks for answer1.2KViews0likes3CommentsSOAPUI free making error saves of its project
Hi, I installed soapUI 5.5 free and after few days I saved the project by clicking on him. I did it multiple times. SoapUI crashed. I tried to import the last saved project and soapUI load him only as ikon with X - badly loaded. I tried to set-up autosaves to 0. Same with another save, new installation. I have now SoapUI 5.4 free like before 2 weeks. Same. I remember that I install ready and uninstall it before 2 weeks. when I see XML in folder explorer it's associated with some office XML bad stuff. I changed it to soapUI. SAME. now I must work in remote with the licence to 30 days but need to solve it till the end of the week because I don't have much RAM on it. restart had no effect. My colleague has the same problem - may not import my project save. Any clues on how to solve it?Solved5 years agoPlace ReadyAPI QuestionsReadyAPI Questions914Views0likes1CommentRe: Validating header values in REST response
try this sample code (valuesin UpperCases change): //Validate request nodes REST // the library import import groovy.json.JsonSlurper //Validate response nodes REST //def requestMessage = message.Exchange.request.requestContent def responseMessage = messageExchange.response.responseContent def json = new JsonSlurper().parseText(responseMessage) //assert node values // syntax: assert json.JSONPATH.ELEMENT.toString() COMPARE SYMBOLS LIKE IN IF (>,<,>=,<=,==,!=,you may use as comparing value "null") def headers = messageExchange.getResponseHeaders() assert ['HTTP/1.1 200 OK'] == headers["#status#"] : "Test Case HTTP Erorr: " + headers["#status#"] log.info "Header status" + headers["#status#"] assert ["YOURSERVER"] == headers["Server"] : "Test Case Server Erorr: " + headers["Server"] log.info "Server: " + headers["Server"] assert json.response.responseHeader.toString() != null : "responseHeader is empty: " + json.response.responseHeader //validation on responseHeader is not empty log.info "responseHeader is: " + json.response.responseHeader assert json.response.responseHeader.ELEMENT.toString() != null : "ELEMENT is empty: " + json.response.responseHeader.ELEMENT //validation on ELEMENT is not empty log.info "providerId is: " + json.response.responseHeader.providerId assert json.response.responseBody.returnCode.toString() == "0" : "returnCode is not 0: " + json.response.responseBody.returnCode log.info "returnCode is: " + json.response.responseBody.returnCode //check for attachments assert messageExchange.responseAttachments.length == 0 : "Response Attachments is not NULL" log.info "Number of atachments " + (messageExchange.responseAttachments.length) // some other thing /* testStepName = messageExchange.modelItem.testStep.name //to get the Test Step Name log.info testStepName xmlHold = messageExchange.responseContentAsXml.toString() //to store the response as Xml */6 years agoPlace ReadyAPI QuestionsReadyAPI Questions4.1KViews0likes0Comments