Based on the thread Jmeter - Compare/assert multiple data: Data from JSON against data from DB i manage to/and i need to do some enhancement how i verify the data.
This time i need to compare: Data from JSON
[
{
"approveTime": 1582543485,
"status": 0.1,
},
{
"approveTime": 1582543463,
"status": 0.2,
},
{
"approveTime": 1586355699,
"status": 0.3
}
]
Against: Single row returned from DB
approveTime status
1586355699 0.3
Using JSON extractor i am capable of getting all the data from the JSON with _ALL suffix:
as: 1582543485, 1582543463, 1586355699
And i am able to compare/assert as:
if ( vars.get("approvetime_GW").contains(vars.get("approve_time_DB")) == false ) {
AssertionResult.setFailure(true);
log.warn(vars.get("approvetime_GW") + " vs. " + (vars.get("approve_time_DB")) )
}
and, is working perfectly fine.
The whole script:
JSON is generated in the ${__V(url_${__intSum(${__jm__Loop Controller__idx},1,)},)}
from the Loop controller
, then overwritten in the next iteration.
Data from DB is generated in the 001_2 JDBC
, also overwritten in the next iteration, so data is dynamic on the every single run
But, in this way i am afraid to have some false positive
results, and i am curious is there any better way how i can assert my data using equals
method rather than contains
, so initially i can loop through all the approveTime's
, and then i can assert it using equals
method?
Any help is appreciated!