header
header
Main Menu
Home
Eviware Store
Downloads
Products
News
Forum
Eviware Blog
Search
FAQs
Customer Area
Support
Documentation
Tutorials
CookBook
Downloads
Forum
Login Form
Welcome, Guest. Please login or register.
November 22, 2008, 11:13:33 am
Username: Password:
Login with username, password and session length

Forgot your password?
 
Reading test data from into datasource and to feed that to the test case
Welcome, Guest. Please login or register.
November 22, 2008, 11:13:33 am
Home Help Search Login Register
News: The Forums are up! Welcome to eviware.

+  Eviware Forum
|-+  soapUI
| |-+  soapUI
| | |-+  Reading test data from into datasource and to feed that to the test case
« previous next »
Pages: [1] Print
Author Topic: Reading test data from into datasource and to feed that to the test case  (Read 642 times)
Shashi
Newbie
*
Posts: 12


« on: March 27, 2008, 09:58:32 pm »

Hello,

I have testdata.properties in the format for example
name1=data1,data2,data3

I have a properties test step defined reading the data from this properties file for the property name = name1

I also have a data source and data source loop test step to read the data from this properties file and to loop through the data with comma separation between data.

The idea here is to have the datasource read the file and loop through the data from 1 through 3 and feed each one at a time to the properties step.

The request is built to take the data from properties like ${Properties#mesLotName}

I am not sure if this is the right way to set up the steps in this order to achieve data driven testing looping through a set of test data.

But it is not working the way I expect it to. It is reading the datasource but putting the entire line with comma as the property value so the response is NullPointerException where it cannot qualify the data input.

Could someone please let me know what is the best way to fix this scenario or if there an alternative to this?

Any help is much appreciated.

Thanks
- Shashi
Logged
omatzura
Administrator
Hero Member
*****
Posts: 1,425


« Reply #1 on: March 27, 2008, 11:56:14 pm »

Hi Shashi,

If I understand this correctly you want to run a request for each of the 3 values in name1. I'm not sure if you really need the Properties step, as far as I can see you will need to do as follows:

1) Change the file to contain one row for each set of data, where columns are separated with ','. In your case there seems to be only one column, so the file should be

Code:
data1
data2
data3
etc..

2) Create a DataSource step with the DataSource type set to File and pointed at the above created file

3) Define one property in your DataSource step named mesLotName

4) Add a request after this DataSource step containing

${<Name of DataSource Step>#mesLotName}

5) And finally a DataSourceLoop that loops back to the request step for each row in the DataSource

When running this, the DataSource will read the comma-separated file one row at a time and assign the only value on each row to its mesLotName. The request will "use" this value and the DataSourceLoop will loop back until there are no more rows..

Ok.. hope I got it right, let me know!

regards,

/Ole
eviware.com
Logged
Shashi
Newbie
*
Posts: 12


« Reply #2 on: March 28, 2008, 12:09:47 am »

Thanks for the reply with detail instructions.

It was a perfect solution. thanks again.

I do have an extended question as I am new to Soap ui pro.

I have a groovy assertion to save the response file onto my system so I can parse and analyze the result later.

Is there a simple way to say all the three responses into different files so I can parse them and get the test results?

I am doing this save and parse method because I want to be able to validate the data in some particular tags in the Soap response.

Regards
- Shashi
Logged
omatzura
Administrator
Hero Member
*****
Posts: 1,425


« Reply #3 on: March 28, 2008, 12:21:57 am »

Hi,

easiest way to save the entire response to files would probably be to create a Groovy Script Step after your request, containing something like the following:

Code:
def datasource = testRunner.testCase.testSteps["<Name of DataSource>"]
def outFile = new FileOutputStream('response-' + datasource.currentRow + '.txt')
outFile.write( context.expand( '<Name of Request Step>#Response' ))
outFile.close()

Hope this helps!

regards,

/Ole
eviware.com
Logged
Shashi
Newbie
*
Posts: 12


« Reply #4 on: March 28, 2008, 11:57:03 pm »

Hello,

I am able to save the response into the file. I was able to do this with the assertions as well. I have moved the assertion to a test step now.

But the file comes out empty. Could it be the problem where the file object is still not closed completely and the next request is trying to access the same object?

Thanks
- Shashi
Logged
omatzura
Administrator
Hero Member
*****
Posts: 1,425


« Reply #5 on: March 29, 2008, 11:28:01 am »

Hi,

are you maybe not closing the file when you are finished? Or not flushing it between requests?

regards,

/Ole
eviware.com
Logged
Shashi
Newbie
*
Posts: 12


« Reply #6 on: March 31, 2008, 06:16:53 pm »

I have outFile.close() right after I write the response to the file. It is not able to capture the responses.

Instead if I out the same script as a script assertion, it is able to write the response to the file. But the draw back is I get only one file with the last request and response. I need to save all the responses.

I want to try some try catch and finally block to handle to this situation where I can force things a bit. for that, I need some help with Groovy scripting. Can anyone point me to a good source on Groovy where I can see the usage of the scripting language and also some examples?

Thanks
- Shashi
Logged
omatzura
Administrator
Hero Member
*****
Posts: 1,425


« Reply #7 on: March 31, 2008, 06:53:43 pm »

Hi,

the Groovy UserGuide is what I can recommend; http://groovy.codehaus.org/User+Guide

Can you share your entire script so I can try to see whats going wrong?

regards!

/Ole
eviware.com
Logged
Shashi
Newbie
*
Posts: 12


« Reply #8 on: March 31, 2008, 07:16:10 pm »

I have this resolved now. I had to change the order if the test steps (I was not aware the order matters)

Now I have the responses saved for all the requests. The idea is to write programs to extract information to have test results compared with expected results.

Thanks for all the information Ole and I will use the groovy site as I will be writing more and more of that.

Logged
Shashi
Newbie
*
Posts: 12


« Reply #9 on: April 01, 2008, 07:31:47 pm »

I was reading a tutorial on Soap ui pro where we could create properties on response and create a transfer to transfer the value of the properties from the response to the property. that link also had a data source loop to be created to get the properties for all the requests posted to the service.

I am trying to parse out the response to get some specific values from the response. Initial thought was to save the response a files and to write a java program to parse the response. But for testing maintainability is a bug thing with this approach.

Is this configurable in soap ui pro by using properties and transfers? Is yes, can someone tell me how?
Logged
Pages: [1] Print 
« previous next »
Jump to:  


Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
header header
header
header