Reputation: 1
I am very new to Jmeter and was hoping to get some direction on how to achieve this task.
I am supposed to write a Jmeter which does following:
I have achieved #1 using CSV Data Set Config. But really need help with #2.
My csv file has following format: fieldname 1,fieldname 2, fieldname 3 value1,value2, value3
I can have multiple csv files to compare the results with. I want to use JSR223 assertion to dynamically check fieldnames from csv and compare value for that fieldname with value returned in API response. fieldname in API response will be same as fieldname in the csv. So, if I can write a generic code that picks fieldname from csv and then compares its value with fieldname from API response, it will work as long as fieldnames are set properly in the csv file.
Can anyone point me to a sample code that does this or Guide me on how to approach this.
Any help will be much appreciated.
Upvotes: 0
Views: 318
Reputation: 168157
We cannot give you the "sample" code because your question doesn't have any API response details.
So far I can only provide the following "samples"
CSV file can be read in Groovy into an array of lines like:
new File('/path/to/your/csv/file').readLines()
JavaDoc: File.readLines()
API response can be obtained within the JSR223 assertion as follows:
prev.getResponseDataAsString()
You may find Scripting JMeter Assertions in Groovy - A Tutorial article useful.
Upvotes: 0