i have written script verify field types, i'm not sure if being validated correctly. want verify expected fields seen. bsf assertion:
import groovy.json.*; def response = prev.getresponsedataasstring(); def json = new jsonslurper().parsetext(response) def eventname = json.event_name (eventname.getclass() == string) def eventdate = json.event_start (eventdate.getclass() == date) def attendeelimit = json.attendee_limit (attendeelimit.getclass() == integer) def ordercount = json.order_count (ordercount.getclass() == integer) def attendancelimit = json.attendance_limit_on (attendancelimit.getclass() == string)
if want check json response data types change lines like
(eventname.getclass() == string)
to
assert eventname instanceof string
see groovy testing guide details
i suggest switching fro bsf assertion jsr223 assertion able compile script , cache hence script perform better. see beanshell vs jsr223 vs java jmeter scripting: performance-off you've been waiting for! article comprehensive explanation , scripting best practices.
there json path assertion available via jmeter plugins, 1 used check response content
Comments
Post a Comment