0

I'm trying to do data driven testing with my JEE application in the free version of SOAP UI 4.6.1. I found this: http://www.soapui.org/Data-Driven-Testing/functional-tests.html. The problem is that I can't figure out how to do the same thing with my web requests.

All I want to do is suck in a user/password and then run through a bunch of pages. It seems like I could use a groovy script for this, but I have no idea how to get started and how to fill the properties being POSTed for my web request from the groovy script.

Thom
  • 14,013
  • 25
  • 105
  • 185

4 Answers4

2

I could not find how to deal with Excel in the free version. If you are looking to do data driven Load testing then you need some kind of data source. However, I have managed to do it with the help I found on the following URL.

http://things-i-do.co.uk/2012/06/15/data-driven-testing-with-soapui-free-edition/

In my hypothetical application, I have to pass EmployeeId as a parameter in to the SOAP request.

I defined a text file data.txt which contains Employee IDs. Then I defined a property (With default value 0) named DynamicEmployeeId. In the test case request I have replaced the hardcoded value of employee Id with the following expression.

`${#TestCase#DynamicEmployeeId}`

In the test case property window , open "Setup Script" tab and define the Groovy script to read the file contents randomly and populate the property from the file in each request.

Example Groovy Script:

      def inputFile = new File("C:\\Users\\JAYARAJ\\Desktop\\SOAPUIPOC\\data.txt");
       def urlList = [];
       addUrlsToList = {urlList.add(it)};
       inputFile.eachLine(addUrlsToList);
       def randomIndex = (int)Math.random()*urlList.size; 
       def randomUrl = urlList.get(randomIndex);
       def tc = testRunner.testCase;
       tc.setPropertyValue("DynamicEmployeeId",randomUrl);

Create a load test and run it . You can see that each request is populated with a separate input value.

Rao
  • 20,781
  • 11
  • 57
  • 77
0

Looks like you are using the OpenSource version of soapUI. This version doesn't support reading data from excel, xml or such you'll have to use external library to do that.

If your data source is excel, or one of the other Ms Office products use either scriptom or jxl. I had some trouble making scriptom work with soapUI so you could check out my SO question on that.

There is a really useful site that you could check out for assistance in using jxl. I think i have noticed jxl jar in soapUI so maybe jxl is now supported inhouse now..not sure.

If your data source is xml you could use groovy's inbuilt support for xml to get data from xml. Check this site for available options.

And if your data resides in a db you can simple connect to it and query data out of the db. Here is a Google search result for "soapUI groovy db"

Finally if i am wrong and you are using the Pro version then just use the data source step to load your data and then use the data loop step to loop back...make sure the loop points to the step after the data source loop not the data source step.

Its actually really very easy to do this.

Hope this helps.

Community
  • 1
  • 1
Abhishek Asthana
  • 1,857
  • 1
  • 31
  • 51
0

I finally found soap UIs scripting help here: http://www.soapui.org/Scripting-Properties/working-with-properties.html.

I changed the test step to reference the property in the test case like this:

${=testRunner.testCase.getPropertyValue( "userId")}

Then wrote quick groovy script as the first test step that stored my users in a static array and, on each run, stored the next one in the test case property. This worked like a champ.

I could have used groovy and read the records out of my database or a flat file, but wasn't that ambitious yet. Perhaps the next time.

Thom
  • 14,013
  • 25
  • 105
  • 185
0

Found following post very useful. rather than using loadTest(not a good way to achieve goal).

http://testautomationnoob.blogspot.in/2012/10/soapui-data-looping-with-groovy-script.html

Idea behind this is to use do ... while kind of structure.

first initialize your properties in TestCase Level Setup Scripts.

perform your testcase

and at the end, add a groovy step which updates the property(like increment by one , read a new value from file) and use

 testRunner.gotoStep(0)

to navigate back to first teststep.

EDIT: following blog even makes it more clear and manageable https://learnsoapui.wordpress.com/2012/05/19/groovy-datasource-teststep-dataloop-teststep-using-groovy-in-soapui/

Kavan
  • 569
  • 4
  • 21