Ask a Question

Automate SoapUI

TvO
Occasional Contributor

Automate SoapUI

Hi There,

 

I wonder; is there anyway to 'Automate' SOAPUI entirely?

I mean; not only running tests, but also making them?

And besides making them, also have stuff like adding and using environments and Usernames/Passwords automatically? (for instance; make and use them for every project encountered in folder X??)

 

What i would like to do, is having a list with for example 4 colomns (Name; WSDL; Environment; Username/Password) and let SoapUI make a project for each line in that list.

Is there anyway to make this happen?

 

 

20 REPLIES 20
rupert_anderson
Valued Contributor

Re: Automate SoapUI

Hi there,

 

Yes, if I'm understanding your aim right, I would say that SoapUI projects can quite easily be created, engineered and executed programatically.

 

These previous posts have examples along the lines of (but not exactly like) what I think you are asking about:

 

(REST Example) http://community.smartbear.com/t5/SoapUI-Open-Source/How-to-create-REST-project-using-Groovy-script/...

 

(SOAP Example) https://community.smartbear.com/t5/SoapUI-Open-Source/How-to-get-parameter-of-SOAP-operation/m-p/997...

 

Is this the sort of thing you mean?

 

Regards,

Rupert

Author of SoapUI Cookbook
nmrao
Community Hero

Re: Automate SoapUI

Let me correct first point of yours - Automate the tests using SoapUI.

While your objective is good, too broad, you have to proceed one step ahead each time.
Anything is possible mostly, provided you have the ideas clear, what you want, issue /problem is clear if any, with some programming skills, thurst for learning & patience.

One point I am divert is that, creating tests automatically unless you are using data driven tests as it is more easy to create test cases in SoapUI manually than automatic (even for programmers) as it is more productive than writing code for ourself and possible introduce more bugs.

 

To your other point regarding environment, you can use of Project level properties and use property expansion where needed. Those can also be dynamically passed to testrunner.bat/.sh (command line test execution utility provided by SoapUI) using -P <property>=<value> without even modifying existing project if environment changes. Of course, instead of passing each parameter individually at commandline, the better approach would be to use property file (one for each environment)



Regards,
Rao.
TvO
Occasional Contributor

Re: Automate SoapUI

Hi There,

 

Thanks for replying 🙂

 

Yeah, it seems to me like a small step...

 

At this moment, i make projects by adding an name, WSDL url and click Yes a cpl of times. Soapui does the rest and when its finished, all i have to do is put some values in the fields of the test case.

 

I have to make about 60 projects in order to test every service we use. We have a lot of ongoing projects, so i have to do this frequently cause our services change a lot and i do not always exactly know which ones are altered, so best thing for me is to 'reload' the wsdl each time or to delete all projects and make new ones.

 

So i was hoping there was some sort of batch function that reads the url from an excel list and makes the project automatically (so not filling the testcases, that i can automate another way by making them data driven, my goal atm is only making projects automatically).

 

I now understand it can be done, but you have to use groovy or java for that (which i both don't know yet), so for now it looks like i have to do it the 'old fashioned' way..

 

rupert_anderson
Valued Contributor

Re: Automate SoapUI

Hi,

 

Yes, I think your assessment of the options for what you want to do is correct. Generating SoapUI projects, testcases, teststeps and assertions is very doable, and a good option, but is certainly DIY territory i.e. requires basic java or groovy, some knowledge of SoapUI objects and patience. If you want to work on this, I'll try to help you where I can, just start small and build up.

 

Just for completeness, its maybe worth mentioning that, once generated, SoapUI persists its objects as XML in the project file, as you may be aware. Some people also copy/paste/replace a copy of the project file xml using a standard text editor and thus build up the project structure they need this way - it can work too - but, I have generally only done this for tweaks, but others may have done it on a larger scale!

 

Good luck with it and let me know if you need any scripting advice,

Regards,

Rup

Author of SoapUI Cookbook
TvO
Occasional Contributor

Re: Automate SoapUI

Hi Rupert,

 

You know anything of scripting in Groovy?

 

I got some that seems to work, but there is 1 thing i can't seem to figure out.

What i have so far:

1: excel with 2 columns; name and url

2: project with datasource and groovy script.

 

I open the project en when i run it, it first gets the name and url from the datasource

It then makes a project with the wsdl (url) from the datasource.

 

That goes well!

 

Now i need to add the next step: adding a testsuite and testcase.

I have this working also, except for 1 annoying thing...the testsuite and testcase are added under my original project and not under the one i just made.

 

here is the script i found and am altering:There is something wrong with the red part...Can you see what i am doing wrong?

 

Thanks in advance!!

 

//some blabla, dunno what for

 

import com.eviware.soapui.impl.wsdl.*
import com.eviware.soapui.impl.WsdlInterfaceFactory

 

//getting variables URL and Name


def url = context.expand( '${DataSource#url}' )
def currentProject = testRunner.testCase.testSuite.project
def project1 = testRunner.testCase.testSuite.project
String projectName = context.expand( '${DataSource#naam}' )

 

//guess this actually makes the project


WsdlProject project = currentProject
.getWorkspace()
.createProject(projectName, new File(projectName + ".xml"))
WsdlInterface iface = WsdlInterfaceFactory.importWsdl(project, url, true )[0]

 

//something is wrong here. My goal with these lines is to make the newly made project active so that the suite is made in that project
//Doesn't work! I need to switch from project A to Project B here...


import com.eviware.soapui.impl.wsdl.*
WsdlProjectPro project2 = new WsdlProjectPro('${DataSource#naam}');
currentProject = testRunner.testCase.testSuite.project2.name == '${DataSource#naam}'

 

//here the suite and testacses are made


suite = context.testCase.testSuite.project.addNewTestSuite("test")
tc = suite.addNewTestCase("test case")
context.testCase.testSuite.project.save()

 

 

ratima29
New Contributor

Re: Automate SoapUI

Is DELETE method allowed in SOAPUI open source tool?

 

I am facing this error.

 

HTTP/1.1 405 Method Not Allowed
Date: Tue, 04 Apr 2017 11:42:07 GMT
Server: Apache/2.2.15 (CentOS)
X-Powered-By: PHP/5.6.30
Allow: GET, POST
Content-Length: 0
Connection: close
Content-Type: text/html; charset=UTF-8

 

 

rupert_anderson
Valued Contributor

Re: Automate SoapUI

Hi,

 

I think the DELETE method was certainly OK last time I tried.

 

Is it not that the Apache sever on your CentOS box only has GET, POST methods allowed? This can be quite common for historical reasons.

 

Thanks,

Rupert

Author of SoapUI Cookbook
zen_paul
Occasional Contributor

Re: Automate SoapUI

Looking at what you want to do, using something like Jenkins to kick of a specific test or set of tests might be useful. We have several projects that we run using Jenkins, both kicked off manually or kicked off according to a schedule. It's pretty easy to do and can be set up so that the tests are running in their own workspaces, and thus isolated from each other from running the test point of view. 

 

Thus you don't need to create the test projects each time, the test projects are defined once in SoapUI, but you just choose the test project you want to run from an existing list of test projects. Might mean you need less groovy skills to programatically create SoapUI projects on the fly.

 

Just a thought and a different approach that might meet your needs.

nmrao
Community Hero

Re: Automate SoapUI

It is recommended not to cross post. Please open a separate topic for this and no need post in the unrelated topic.


Regards,
Rao.
cancel
Showing results for 
Search instead for 
Did you mean: