Contributions
Custom properties don't save when I execute project from Command Line
Hi. I have a ReadyAPI/SoapUI Pro Project that I execute with a command line from a scheduled job. In the TearDown Script of the Project, I set some Project Custom Properties which are to be used in the next Run. e.g.project.setPropertyValue( "LastRunValue", theVariableValueIWantToStore); Thisworks when I run the Project manually with the ReadyAPI UI open. I see the value get set between runs and the scripts function as I would like. However, when I run this project from a command line the Custom Property Value gets set to it's 'default', i.e. what the value is when I closed and saved the project. Can someone please advise if: - there is a way to save the new Custom Property in the TearDown? e.g. project.save; OR - they know where and how I could save this value so it is available for the next execution from a command line so that it is contained within the Project. Help and advice will be greatly appreciated. Many thanks, Paul7 years agoPlace ReadyAPI QuestionsReadyAPI Questions815Views0likes1CommentRe: Iterate through the TestSuites in my Project TearDown Script (using Groovy Script)
Hi All. Thanks for comments/help on this.Thanks to people in other posts too for partof the email code. Here is my full solution that I hope will help others too :-) This will loop through each Test Suite in a project getting the Test Suite name and its status, then send a summary email. Put the code below in your PROJECTTeardown Script. Also, if/when youLaunch TestRunner, select to output the report to a root folder (which will beincluded in the email).This code could be improved by taking the input parameters and setting the report output location dynamically.Each environment that you have set up will output to a different location (You may need to create the .../EnvironmentName/ProjectName/ directories in the root location) I set the To Email Address(es) as a Project Property but have hardcoded in the code below. I set up a scheduled job which calls a .bat file to Launch the Test Runner so that this runs test checking our environments regularly. It only emails when it detects failures but you can change this easily.I intend to move thisto using QAComplete and the Scheduler. I am using ReadyAPI with SoapUI Pro. Cheers, Paul ------------------------------------------------------------------------------------------------------- import javax.mail.internet.*; import javax.mail.* import javax.activation.* import static org.junit.Assert.assertEquals; import java.util.List; import org.junit.Test; import com.eviware.soapui.impl.wsdl.WsdlProject; import com.eviware.soapui.model.support.PropertiesMap; import com.eviware.soapui.model.testsuite.TestCase; import com.eviware.soapui.model.testsuite.TestRunner; import com.eviware.soapui.model.testsuite.TestRunner.Status; import com.eviware.soapui.model.testsuite.TestSuite; def testCaseName = "" def testSuiteNames = "" def failedCount = 0 def results = "" //project details and failed results def passedResults = "" def message = "" def testSuiteRunner = context["#TestSuiteRunner#"] results += "ReadyAPI Project : <b>" + project.name + "</b></br>" results += "Environment : <b>" + project.activeEnvironment.name + "</b></br>" results += "Project File : " + project.path + "</br>" results += "\n<a href=C:\\Your\\Report\\Output\Root\\Folder\\Results\\" + project.activeEnvironment.name + "\\" + project.name + "\\index.html" + ">See the Latest report here</a></br></br>"; results += "<b>Failed Test Suites" + "</b>" + "</br>" passedResults = "<b>Completed Test Suites</b>" + "</br>" if( testSuiteRunner != null ){ for(r in testSuiteRunner.results ) testSuiteNames = testSuiteRunner.results.testSuite.name for (int i = 0; i < testSuiteNames.size(); i++) { String testSuiteStatus = testSuiteRunner.results.get(i).status if (testSuiteStatus.equals("FAILED")){ testCaseName = (testSuiteNames.get(i)) + " <b style=color:red>" + testSuiteStatus + "</b></br>"; failedCount ++; results += testCaseName; } else { testCaseName = (testSuiteNames.get(i)) + " <b style=color:green>" + testSuiteStatus + "</b></br>"; passedResults += testCaseName; } } } if (failedCount > 0){ subject = project.activeEnvironment.name + " Environment : " + project.name + " Testing Failed" toAddress = project.getPropertyValue( "SendEmailFailuresTo" ) fromAddress = "Automated_Tests@Yoursmtphost.com" host = "Yoursmtphost.com" port = "25" //You may usea different port and possibly username/pwd Properties mprops = new Properties(); mprops.setProperty("mail.transport.protocol","smtp"); mprops.setProperty("mail.host",host); mprops.setProperty("mail.smtp.port",port); message += results + "</br>"; message += passedResults Session lSession = Session.getDefaultInstance(mprops,null); MimeMessage msg = new MimeMessage(lSession); //tokenize out the recipients in case they came in as a list StringTokenizer tok = new StringTokenizer(toAddress,";"); ArrayList emailTos = new ArrayList(); while(tok.hasMoreElements()){ emailTos.add(new InternetAddress(tok.nextElement().toString())); } InternetAddress[] to = new InternetAddress[emailTos.size()]; to = (InternetAddress[]) emailTos.toArray(to); msg.setRecipients(MimeMessage.RecipientType.TO,to); InternetAddress fromAddr = new InternetAddress(fromAddress); msg.setFrom(fromAddr); msg.setFrom(new InternetAddress(fromAddress)); msg.setSubject(subject); msg.setText(message, "UTF-8", "html"); Transport transporter = lSession.getTransport("smtp"); transporter.connect(); transporter.send(msg); }8 years agoPlace ReadyAPI QuestionsReadyAPI Questions1.4KViews0likes0CommentsIterate through the TestSuites in my Project TearDown Script (using Groovy Script)
Hello. All I want to do to start, is iterate through the TestSuites in my Project TearDown Script (using Groovy Script) and get theName and Status of eachTestSuite (whether it Passed or Failed). If I can get more details (test cases/test steps that failed etc) that would be a bonus. I can not find an example or the properties to do this and have tried multiple methods. Does anyone have the code to dothis please? Many thanks, Paul P.S. This is the best I've got so far butthere must be a better/cleaner way to approach this so I can get the resultstoo? import static org.junit.Assert.assertEquals; import java.util.List; import org.junit.Test; import com.eviware.soapui.impl.wsdl.WsdlProject; import com.eviware.soapui.model.support.PropertiesMap; import com.eviware.soapui.model.testsuite.TestCase; import com.eviware.soapui.model.testsuite.TestRunner; import com.eviware.soapui.model.testsuite.TestRunner.Status; import com.eviware.soapui.model.testsuite.TestSuite; def testCaseName = "" def testSuiteRunner = context["#TestSuiteRunner#"] if( testSuiteRunner != null ) { for(r in testSuiteRunner.results ) testCaseName += testSuiteRunner.results.testSuite.name }8 years agoPlace ReadyAPI QuestionsReadyAPI Questions1.5KViews0likes3CommentsRe: How do I set the endpoint as an Environment Variable in an HTTP Request
Thank you Tanya. I found another way to do it. You can create a Custom Property(e.g.https_endpoint)for each environmentvalue and then replace the Endpoint stringwith ${#Project#https_endpoint} It will replace at runtime depending which environment is selected. Cheers, Paul9 years agoPlace ReadyAPI QuestionsReadyAPI Questions1.8KViews2likes0CommentsHow do I set the endpoint as an Environment Variable in an HTTP Request
Hi. I can set the Environement and add an Endpoint which gets picked up by a REST request. However, I can't seem to get set an EnvironmentVariable or pick up the endpioint for a HTTP Resquest Step. Does anyone know how to do this please? I have tried adding a Custom Property called https_enpoint in the Environment editor and the replacing the Enpoint in the request with ${[#env#]https_enpoint[#value]} but this does not seem to work. Can anyone help or know how to do this please?Solved9 years agoPlace ReadyAPI QuestionsReadyAPI Questions1.8KViews0likes2Comments