JMeter Beanshell sampler that runs when HTTP Request Sampler fails

Jake Zidow

I need a Beanshell sampler that runs only when a specific HTTP Request Sampler fails. I want this so I can write certain variables to the terminal console when this failure occurs during test execution.

I know I can save the http response to a file upon failures [using built in jmeter component Save Responses to File] and include variables in the name of the file saved, but this is too heavyweight for what I am trying to achieve.

riversidetraveler

Why not set up a beanshell sampler with an if condition that tests the result's HTTP status? The script would look something like this:

if (!ctx.getPreviousResult().getResponseCode().equals("200")) {
    log.info("Your log message here.");
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Jmeter, BeanShell Sampler and Summary Report

Error running sampler with http request- Jmeter

JMeter - Exception when using Beanshell as JSR223 Sampler with file

Error in Beanshell Sampler JMeter for parsing RegularExpressionExtractor

Parsing string to integer in BeanShell Sampler in JMeter

JMeter: Is it possible to add HTTP Request sampler during run?

JMeter enable/disable HTTP Request Sampler upon certain condition

Jmeter - Is it possible to skip remaining samplers when one sampler fails

Meaning of HTTP request sampler data

Unable to append to next line in a file through beanshell assertion sampler in Jmeter

Store Jmeter sampler properties value using beanshell preprocessor

Writing Variables using Beanshell Sampler in JMeter into a txt/csv file

Jmeter: Access all results from all threadGroups from JSR223 Sampler or BeanShell Sampler in TeardownThread

JMeter - Allow simple sumbit of request (or any Sampler)

Jmeter - Increment value before each sampler request

JMeter ClassNotFoundException on Java Request Sampler class

How to remove empty HTTP request params from Jmeter HTTP sampler with JAVA/Groovy

Get error when run WebDriver Sampler in jmeter

I want to fail Beanshell sampler when my script is not conditions not satisfied

Need help in capturing HTTP Request sent from View results tree sampler in Jmeter

How to let Jmeter Http request sampler preload and resue the upload file in its upload test?

How to use Http Request Sampler to click on a checkbox

Jmeter - WebDriver Sampler

JMeter - How to pass output from HTTP Sampler as input to OS Process Sampler

Gibbs sampler fails to converge

Jmeter is not running the ssh sampler when it run by hudson and it the run the ssh sampler when it is run manually

Get and set JMeter's properties in Java Request Sampler

How to add a JDBC request sampler in JMeter-5

In Jmeter, A perquisite sampler request should be a part of transaction controller or not?