Jmeter Parametrization - jmeter

I'm very new to Jmeter. I need help with the input data file for jmeter.
Here is my situation.
My test data file structure is like this:
Test Case Name = XXXXXX11
RequestData = AAAAAAAAAA11
Expected Result = BBBBBBBBB11
Test Case Name = XXXXXX22
RequestData = AAAAAAAAAA22
Expected Result = BBBBBBBBB22
and so on ....
Now, I have to send the http request and verify the expected using Jmeter (Maven & Continuous Integration).
How can I parse the given file and verify the expected result?
I have tried the following:
__StringFromFile - but i don't know how to look for the line which has Request data or Expected result;
userParameter - but not sure how to pass values on runtime.
Could any of you please help me?

Do you have single test-case per file (i.e. single appearance of "Test Case Name",...,etc. in file)?
If so then you can possibly try to use custom Variables From CSV File plugin from Jmeter Plugins project.

My suggestion would be to convert your file to csv (with any delimiter you like). The first row becomes your heading, and each additional row becomes your data you want to pass in or validate. For example:
Test Case Name|Request Data|Expected Result
XXXXXX11|AAAAAAAAAA11|BBBBBBBBB11
XXXXXX22|AAAAAAAAAA22|BBBBBBBBB22
You can load this data in to your test plan using the CSV Data Set Config. Once you do, you'll be able to loop through each row of data if you set your Thread Group to Loop Forever. Then all you need to do in the test case is refer to your variables from the csv file like so:
${Test Case Name}.

Thank you so much guys!
I just wrote a bean shell script to parse the CSV file and stored all the request & response in the array and then created a for each loop around my http sampler. That met my requirement.
Thread Group
Beanshell preprocessr (To parse my CSV and to store it in an array)
For each loop (loops thru the array)
http sample
response assertion
Results

Related

Jmeter - Need to check empty tags in SOAP request

I have a SOAP request. I need to use jmeter to test multiple requests for same method, each time passing one missing element.
How can I achieve this ?
I tried writing the tags into csv using CSV data config , but I am unable to enter empty values in the csv, each time for a different tag in each csv row.
Any help would be appreciated. Thank you.
The CSV Data Set Config will read the value from next line only on the next iteration of the thread (virtual user), you cannot read more than one line within the bounds of a single iteration. You might want to take a look at __CSVRead() function where it's you who decides when to proceed to the next line.
If the __CSVRead() function isn't applicable for your use case be aware that you can build a request body, i.e. XML from CSV file using JSR223 PreProcessor and Groovy language.
See Creating XML chapter of Groovy documentation for more details.

How to hit parameterized url in Apache Jmeter?

This is my test URL " http://appr.seconddemo.org/hitssurveys/survey?uid=113&offerid=311&subid=subvalues&offr_id={Email} "
I want to hit the url 1500 times per second , and want to change the "{Email}" with real value in each iteration.
How it's possible please give me a step by step guide.
Considering that you need to pass the emails from the external file, the most efficient way that we are using in software testing companies is to pass the variable from .csv or .txt files using 'CSV Data Set Config' element of the JMeter.
Please find the steps that you need to follow:
Add a 'CSV Data Set Config' element from 'Config Element' by right-clicking the thread group
Set Filename field with complete path to your .csv or .txt file that contains your emails
Set Variable field as 'Email' [This variable name should be same as you set in your url request]
Ignore first line to False
Set other fields as per your requirement
Now add HTTP Sampler in your Thread Group and set the Protocol, Server Name, Method & Path as instructed in the screenshot:
Create .csv or .txt file and add all emails separated by new line:
Hope this answer is useful.
You can use the CSV Data Set Config. Put all your email credentials in the CSV file and make sure you have put this CSV file in your JMeter /bin directory.
Add a CSV dataset config in your test plan. Your CSV dataset config should be like:
Now in your thread group, define the number of threads you want to execute and then in your sampler put the path as follows:
http://appr.seconddemo.org/hitssurveys/survey?uid=113&offerid=311&subid=subvalues&offr_id=${Email}
Depending on where do your emails live there are following options:
If they are in a text file, each email on a new line you can use __StringFromFile() function like:
If they are in a database you can use JDBC PreProcessor to fetch the data from the database table column and put your request under ForEach Controller
If you need to provide just some random characters you can use __RandomString() function.
More information: JMeter Parameterization - The Complete Guide

HTTP Request path needs to be parameterized with UUID and a random URL

URL format is
www.something.com/something/api/{uuid}?code=gomundw0gjq2kbvc3g63whfr9usap5rurjaq5vui5vm6xbt9hhqa8hbcpto4yatwpn26v42t9
I need to make several calls to this GET Url and check performance of the feature.
uuid here is not just the UUID , but is specific to my application
UUID= accountid+identifierid+uuid, which will look like 1234+1234+123e4567e89b12d3a456426655440000
How should I arrange my Jmeter Test Plan.
My Plan would be:
write UUID generated to a file
Using any preprocessor call the file from file and write program to append to a different value in the csv which is account/identifierid.
Please help on this, can some one explain how I should logically arrange my test plan and code to get data to parameterize my path in HTTP Request sampler.
Thanks in Advance
You need to get accountid+identifierid information stored into CSV file. This is something you need to do on your own.
You can use CSV Data Set Config in order to get the information from that file while your test is running, example configuration would be:
UUID can be generated using __UUID() function
So your HTTP Request sampler configuration would be something like:

Use Beanshell for parametrization in jmeter

Currently my test structure is:
User Defined Variable (Name:CAMPAIGN_ID, Value:100)
Thread Group
CSV Data Set Config (to read external txt file of user ids)
HTTP Request
Beanshell Assertion (use JSON path extractor to extract value of a field using CAMPAIGN_ID configured in UDV)
So my test runs fine with one CAMPAIGN_ID.
Now i want to enhance this test and execute it for 10 Campaigns without updating it in User Defined Variable everytime.
So i created a campaign.txt file as below
Campaign1 100
Campaign2 101
Campaign3 103
Questions:
1. What is best approach to achieve this goal ? should i use beanshell prepocessor to read from txt file and store it in vars.put("Campaign1",100) and use for Each loop to loop through.
2. Can someone please help me with the new test structure and code sample ?
Any help is much appreciated !
Are you trying to loop 2 csv files?
For every rows in an outer CSV file (CAMPAIGN_ID), you need to run all the rows of inner csv file (user_id),then take a look at below example.
http://www.testautomationguru.com/jmeter-looping-2-csv-files/

JMeter - Conditionals and Assertions

I am able to have my test plan set up as so: Thread Group > While Controller > SOAP/XML-RPC Request > CSV Data Set Controller & Response Assertion. When I have one element it is ok, but when I loop through a CSV I get failed.
How do you loop through a CSV (that contains the input parameter values I want to test with) and set an assertion for each please?
E.g. I want to test a currency converter. My Excel sheet contains these rows:
USD,EUR
EUR,GBP
GBP,USD
The jmeter test plan will loop through my Excel and inject each of those parameter pairs to my web service. USD,EUR should return 0.9216, EUR,GBP should return 0.729 etc.
Thanks!
Check the 'CSV Data Set Config' in this post. If it does not clarify, please let me know with your question.
http://www.testautomationguru.com/how-to-test-rest-api-using-jmeter/

Resources