Jmeter Thread Classes Part 3 – PREV

The PREV variable is synonymous with the SamplerResult Jmeter class.  PREV allows your Jmeter script to access thread specific methods and data created by the test sampler.  To see a list of all available methods, please refer to the official Apache documentation.

I have found that these methods are helpful when testing REST API responses:

log.info("Response Timestamp = " + prev.getTimeStamp());
log.info("Response Code = " + prev.getResponseCode());
log.info("Response Message = " + prev.getResponseMessage());
log.info("Response Headers =  " + prev.getResponseHeaders());
log.info("Response String = " + prev.getResponseDataAsString());

01_log

In addition, there are also SET methods that allow you to update specific values during runtime:

prev.setSampleLabel("This thread is fantastic");

prev.setContentType("text/xml");

Leave a comment