How to Debug JMeter Test Scripts
September 13, 2022

How to Debug JMeter Test Scripts

Open Source Automation

Performance tests created using JMeter (or BlazeMeter) are also software. That’s why performance scripts can also contain errors that lead to bugs in the tests themselves.

This blog will explore different ways that you can debug JMeter scripts, including the debug sampler, debug post-processor, and JSR223 sampler. Feel free to read along or skip to the section that interests you the most:

How Can Teams Debug JMeter Test Scripts?

JMeter provides various tools for debugging performance testing scripts. For example, a debugging-related use case is inspecting the values of certain variables in your script. It is possible to see the contents of the JMeter variables used in a JMeter script at any given time. By doing so, you can identify unexpected values stored in variables that can lead to unexpected behavior.

You can use the following JMeter components to debug your performance testing scripts.

  1. Debug sampler 
  2. Debug post-processor 

Debug Post-Processor vs. Debug Sampler

The debug sampler and debug post-processor components help us see variable values in the "View Results Tree" component (if added to the test plan).

The debug features do not work if you run the JMeter scripts using the CLI. The debugging features work only in GUI mode.

One major difference between the JMeter debug post-processor and debug sampler is that the Debug post-processor is used to inspect the properties of its parent sampler. In the View Results Tree tree, the results of the post-processor are shown nested underneath its parent sampler.

Additionally, the debug post-processor contains an additional flag called “Sampler properties,” which is set to true by default. 

How to Use the JMeter Debug Sampler

We will use the publicly available API to explain the JMeter debugging concepts presented in this post. Please note that this is a free public API open only for learning purposes, so don’t put too much load on it.

Step 1: Creating a Test Plan

Let's create a new JMeter test plan using the built-in template “Functional Testing Test [01].”

Debug JMeter test plan

Software testing teams can use this JMeter template for API functional testing, as the name implies.

This template contains a Test Plan, a Thread Group, and a View Results Tree, as shown below.

JMeter test plan template

Let’s rename the test plan to “Debugging in JMeter,” and add two variables to it. The variable names and values are given below:

JMeter Test Plan Variable Name

JMeter Test Plan Variable Value




The thread settings are unchanged. Only the name has been modified for clarity to relate to “Deck of Cards.”

Deck of Cards JMeter thread settings

Step 2: Adding a JMeter Debug Sampler

Now, let’s right-click the Thread Group and add a JMeter “Debug Sampler.” I'll change the name of “Before Everything Debug Sampler.”

The debug sampler is configured to show only the JMeter variables, by default. It is possible to show the JMeter and System properties by changing their flag values.

Adding a JMeter Debug Sampler

How to View Debug Sampler Results

Save the test plan and run it. You’ll be able to see the results of the JMeter debug sampler in the View Results Tree component by selecting the results of the debug sampler. The JMeter variable values will be shown in the “Response Data.”

View Debug Sampler Results

You can see that the test plan level variables protocol and host values are printed.

Debugging the JMeter Variables After Calling an HTTP Request

Let's continue with our example of debugging JMeter variables. We are going to use the website It is a free website made available for learning purposes only. 

We will make a GET API call in this section and then add a debug post sampler afterward. It will help you to see the new “state” of the performance scripts as represented by the values contained in the script variables.

It is possible to create a new deck of cards by calling the shuffle endpoint exposed by the deck of cards API. The URL and the response value are given on the Deck of Cards site and shown below as well.

Deck of Cards API example

The steps to make the API call using JMeter are given below: 

1. Add an HTTP request to call the endpoint. In JMeter, an HTTP request sampler can be added to a Thread Group by right-clicking it and selecting “Add => Sampler => HTTP Request.”

It will be a GET HTTP request by default; we’ll let it be and change the name to Shuffle.

2. Next, provide the variables ${protocol} and ${host} in the fields “Protocol” and “Server name or IP.” The path will be set to the following value:


3. Now, let’s add the deck_count using the “Send Parameters” table below and set the value to 1. The final test plan will look as shown in the screenshot below.

Final test plan

Please note that the process of making a POST http call will also be the same.

This API call will return a JSON value. We can use the JSON Extractor “Post-processor” to extract the value and save it to a JMeter variable. In the case of the JSON provided by the API documentation, we can use the following JSON Path expression to extract the value we need. 


JSON Extractor

4. To see the state of the variables, we will need to add another Debug Processor at the thread level after the shuffle HTTP sampler. I’ll call it “After Shuffle Debug Sampler.”

After Shuffle JMeter Debug Sampler

5. If we run the automation script now, the value of the newly created variable “deckId” will also be printed in the response.

deckID variable in JMeter test response

Using this technique, we can see the value of all user-defined values, which helps us identify potential issues within our performance scripts.

How to Print the Values of JMeter Properties and System Properties

There are various JMeter properties that are set by default. In most cases, there’s no need to change them. But in some niche cases, you may have to change them. 

The same goes for specific system properties. But there is still a chance that these properties could sometimes cause your performance scripts to fail. Maybe the default SSL settings are not suitable for your tests. 

The easiest way to change JMeter properties is by printing these values by changing the relevant flags in the JMeter Debug Sampler. By doing so, we can compare the current values of JMeter properties and System properties to the values you expect and fix any problems. An example of modified JMeter debug sampler flags is shown below:

JMeter debug sampler flags

For debugging the JMeter scripts, we will run them. Since I changed the properties of the second debug controller, the values will be printed in its response, as well as a long list of variables.

Printing JMeter property values

How to Use the JMeter Debugging Post-Processor

A post-processor is a JMeter item that is executed after something has happened. For example, after an HTTP request has been completed. The debug post-processor is used to see specifically the properties related to the parent sampler it is nested under.

In the following example, you will learn how to use a debugging post-processor for inspecting your performance script values for script debugging purposes.

JMeter debug post-processor

Preparing to Use the Debug Post Processor in JMeter Scripts

I’m going to call the draw endpoint of the deck of cards API using the HTTP GET operation. 

Since the deck of cards is a free public API, we must not put too much load on it. I will add a constant timer before the next call. The API input and output specifications are given below.

Deck of Cards API input and output specifications


The test plan will look like the following after the addition.

Updated test plan to debug JMeter scripts

We can use the JSON extractor post-processor to extract the value of the remaining cards and print it using the debug post-processor. To do so, I’ll first add the JSON extractor post-processor to extract a variable named remaining and provide it with the following JSON path expression:


The screenshot given below shows the same:

JSON extractor post-processor

How to Add a Debug Post-Processor to an HTTP Request in JMeter

Post-processors are added to an existing sampler. In this case, we are going to add the debug post-processor to the HTTP sampler named Draw.

We can right-click the Draw HTTP request and select the following menus to add a debug post-processor “Add => Post Processors => Debug PostProcessor.”

If we run the script after completing the above steps, we’ll also be able to see the sampler properties and the JMeter variables. The output will also display the path used for the method call. This path is important because a mistake here can cause script failures. The draw API call contains a value stored in a user-defined variable. If this variable does not contain the correct value, your performance scripts will fail. 

A screenshot of the results:

Add a Debug Post-Processor to an HTTP Request in JMeter

Debugging in JMeter Using a JSR223 Sampler

Adding a JSR223 sampler to your JMeter performance/load testing script is also possible for debugging. A JSR223 sampler is in principle used to execute the code you provide. But you can also use it to see variable values while running scripts too, for debugging purposes. JSR223 supports multiple JVM languages, including Java and Groovy.

I have added a JSR223 sampler to the main Thread Group used in this test. The default programming language selected in the JSR223 sampler is Groovy. I have used it for this example.

We can simply use the following lines of code to print the contents of the user-defined variables deckId and remaining cards in the deck to the JMeter console:"Deck ID: " + vars.get("deckId"))"Remaining: " + vars.get("remaining"))

The screenshot of the exact JSR223 sampler is given below.

JSR223 Sampler to debug JMeter scripts

By running the script, we can see the values in the log pane.

A screenshot of the results printed in the JMeter log is shown below. You can see the contents of the variables defined in your JMeter performance testing scripts for debugging purposes. This screenshot of the results can also help you catch the bugs in your script.

JMeter results log

Bottom Line

In this blog, we explored different ways to debug JMeter tests, from the debug sampler and debug post-processor to the JSR223 sampler. You can learn more about mastering JMeter testing with our JMeter course at BlazeMeter University

BlazeMeter can also take your JMeter testing to the next level. Not only is BlazeMeter 100% compatible with JMeter, but it also contributes to the JMeter open source community, through JMeter plugins, fixes, and documentation. BlazeMeter adds on to JMeter, allowing JMeter users to enjoy additional benefits that add scalability, security, and enterprise capabilities when load testing in the cloud.  

Explore JMeter testing with BlazeMeter in our free trial.

Start Testing Now