soapUi: possible to send list of parameters to test case - groovy

Is it possible to send a list of parameters to a test case / step in soapUI? I want to perform some database validation, and I would like to be able to pass a list of the expected values to the test case and / or step that performs the validation.
I know it's possible to send single parameters ("properties") to a test case, but I don't think that's good enough for this use case. My idea is to write a single "test case" that performs the validation that can be called from other test cases, and they pass in the values they expect to find in the database.

If you can generate the list of Random parameters through Groovy script then the best solution is: Through groovy script set the property field's value and pass this value into request using property transfer. The property field value will change at each and every run of the groovy script.
Now run the request in loop in groovy script.
So we can able to run the one test request multiple times with different parameter values.

We have a similar issue. We need to run multiple XML-files as source files for the sequence of requests. We got about 15 steps in the test, and the only thing that changes is the initial XML.
We solved this by using groovy to set a propperty to a comma seperated list, then pick the first element, remove it from the list, and run the tests. In the end, we return to the "pick first element from list"-step if the propperty is not empty.
This is a goto implementation of a basic loop, and we would prefer to do this differently, but we have not figured out how to (we run soapUI via maven2).

If you are using soapUI Pro, you can create a data source step > request step > dataSource loop step.
dataSource step can take excel, XML, grid as the soure. You need to create a property and select the type of the source.
The next step is running the request.
Then you should create a dataSource loop step. This steps returns to the dataSource until running all the request.
Please check soapui documentation
if you are not using soap Pro version, creating a groovy script is the solution as described with the previous answer.

Related

How to store Body data in post request through jmeter

I am new to jmeter, I am using jmeter to test e-commerce website.
I have manage to script one scenario, which is to add a product in basket and test the response time.
Now, I have observed that when i click Add button on UI, their are two requests which are getting POSTED.
for eg: stocks are updated.
As of now, I have copied the BODY from stock and pasted in jmeter sampler, but in future i may change the Sales order and update scenario, hence i want to store this Body data(Stock request which is updated) of this request dynamically, as it will change corresponding to sales order number im providing.
The problem is I am not able to store the BODY data dynamically(Only if i change the sales order here).
I know i can use pre processor in this matter, but could anyone help me with the code to get the BODY data from the request and store dynamically before sending the sample.
Basically I need a solution where I am just updating my sales order number and rest of the things will be taken care dynamically, in my case the POSTING of Body data for updating the STOCK.
Thank you in advance!
See basically, you're talking about Correlation. As I can understand from your concern. You need the data for the product added to the cart. Which needs data from prev request. This can be easily managed by generating two requests. Extracting from first and using that info for the second one. This will not involve any hardcoding and will work for you in an efficient manner.
Something like:
vars.put('bodyData', sampler.getQueryString())
should do the trick for you, if you put this code into a JSR223 PreProcessor and add this PreProcessor as a child of the HTTP Request sampler which body you need to store - you will be able to access the request body as ${bodyData} later on where required
In the above example:
vars - stands for JMeterVariables class instance
sampler - is for HTTPSamplerProxy
More information: Top 8 JMeter Java Classes You Should Be Using with Groovy

Generate a variable in Groovy JMeter

I have a Thread Group wherein I have three samplers. They are HTML Requests. The first one returns a person and gives me the name, age and address. The second one changes the attribute name of the person but has no response.
The third sampler is the same as the first.
The second sampler isn't working and doesn't change the name.
I want a failure message like: "The name of the person was $(name1) and should be changed to $(name2), but the name is $(name3)" or something like that.
I do the whole things with Groovy so is there any way to generate variables with the output of the first and third request and the input of the second?
Most probably you're looking for Response Assertion, you can conditionally mark samplers as failed depending on various criteria. It might be the case that you won't even need scripting like.
Just add Response Assertion as a child of 3rd request and configure it to expect ${name3} variable to be present in the response (you can use Perl-5 style regular expressions for this as well) and if the name will not be present - the sampler will get failed and you will see the relevant failure message
More information: How to Use JMeter Assertions in Three Easy Steps
I do not think you can do it the way you describe it, because samplers are processed sequentially, so you can not process first, third and go to second request. You might want to re-evaluate your approach.

Parallel execution with TestNG and appium

I'm currently busy with an test automation project for mobile devices and I want to store my results in a database.
I do this with a custom assertclass which I created, this one stores the result.
The layout is as following -> There are runs which contain Tests which contain Steps.
When I want to run in parallel, I create a unique id for the run based on thread and date and store this one in a static list. This is #BeforeTest.
At the #BeforeClass, I search in the list for the right thread and assign the correct name to the variable of the class.
But I receive constantly a Nullpointerexception for the list in the beforeclass or the variable is null while it was filled in in the #beforetest.
What are we missing here? Or how is this done when you need to store a parameter that is generated once for the whole run?
Thanks in advance,
Jonas Vandevelde

How to compare a value in the response with earlier values in soapUI?

I'm working with soapUI and groovy to do a test whether a particular value regenerates again?
I'll have a soapUI request with JSON which gives a id in the response, i should extract tat id and store it in a dynamic location so that the when i run the test case again, i should be able to compare the prev id. if it both matches then the test case should fail, if not then the new value should be added and the when the test case runs now, it should compare the prev two values.
This goes on for a min of 10000 runs. so 10000th id should compare with all the 9999th id to check for repetition. If it exists, it should fail else the test should pass.
Please help me.. Thanks in advance!
March, 2013...wow..sorry for the late answer and hopefully you were able to find an answer to this question.
I do not have access to soapUI right so i cannot offer code for this answer but off the top of my head i would say..instead of saving the value in the dynamic location store it in a test suite, test case or project level property and each time you want to compare..just read that value and compare.
I understand you are going to have to store 10000 times so instead of creating so many properties, store the values in a list or map and store that map in the properties. Every time you need to check the value, you access that property, find what you are looking for an compare.
I'll have access to soapUI tomorrow so i'll try to write some code for you.

How? SOAPUI and Groovy - send different SOAP message (with property from file) each time?

I'm trying to use SOAPUI (4.0) to do load testing, and I want to have each SOAP request be different, with some attribute values and element values in the requests being populated from (for example) a text file.
The SOAP message is going to be the same for each request, except for the several attribute values and element values.
The SOAP message includes an unsigned SAML assertion, and that has some attributes that need potentially be different for each SOAP request. Among these attributes there's one called "IssueInstant" which is basically a date/timestamp string, and an "Id" attribute, which is a unique string per request.
Ideally, I'd like to be able to populate that "Id" attribute value from the text file.
I've been able to populate the IssueInstant automatically in SOAPUI, by including a small piece of Groovy code, to get the current date/time, re-format it, then store that in a property. This Groovy code is in the startup script in the SOAPUI testcase.
In the body of the SOAP message, I have a Subject element that I want to have populated from the text file.
After the IssueInstant, Id, and Subject are populated, I want SOAPUI to send the request.
So, for example, say the text file has:
id0001,cn=foo1,dc=whatever,dc=com
id0002,cn=foo2,dc=whatever,dc=com
id0003,cn=foo3,dc=whatever,dc=com
Then, when I run the SOAPUI load test, I'd like the first request to have Id=id0001 and subject cn=foo1,dc=whatever,dc=com, the second request to have Id=id0002 and subject cn=foo2,dc=whatever,dc=com, and the third request to have Id=id0003 and subject cn=foo3,dc=whatever,dc=com, and then the load test loops back through those 3 sets of values until it ends.
The thing that I'm having a hard time understanding is how to step through the file in the Groovy code and how the Groovy code is suppose to know which line in the text file is the next line from which to build the properties?
I hope that this explanation of what I'm looking for is clear enough. If not, please let me know, and I hope that someone can help.
In soapUI Pro there exist so called DataSource and DataSource Loop test steps. They are used for looping through a set of test data. For example a text file. If you have the ability to use soapUI Pro, I recommend you to have a look at this: http://soapui.org/Data-Driven-Testing/functional-tests.html
Otherwise you have to load the file via groovy.
how to step through the file in the Groovy code
I'm sure you'll find some code snippets via Google.
how the Groovy code is suppose to know which line in the text file is the next line from which to build the properties
Create a test case property with initial value 1. Always after reading a line increment the value by 1. By reading this property in your groovy code you always know which line to read.

Resources