Over a million developers have joined DZone.

A Step-by-Step Debugger for JMeter: It’s Not a Dream Anymore

DZone's Guide to

A Step-by-Step Debugger for JMeter: It’s Not a Dream Anymore

Check out this thorough review of the features of JMeter's step-by-step debugger.

· Java Zone
Free Resource

Managing a MongoDB deployment? Take a load off and live migrate to MongoDB Atlas, the official automated service, with little to no downtime.

We’ve covered various ways to debug scripts in JMeter, but now you have the ability to debug scripts step-by-step and receive updates in real time. Here’s how.

Exit Complexity, Enter Simplicity

When I started to work with JMeter to create scripts, I was (as I’m sure we all do) feeling like debugging my scripts was way too cumbersome a process. By using the Debug Sampler and log() functions, it really felt like the old mainframe debugging days.

I wished we could just have a normal step-by-step debug, just like any normal IDE (integrated development environment), to debug my scripts and find issues.

Now, because of BlazeMeter, that day has finally come. BlazeMeter has created a step-by-step debugger, and here is how to get it:

By using the Plugin Manager (you don’t have it yet ?!) you can get the step-by-step debugger with just four easy steps:

  1. Open JMeter and go to the Options->Plugin Manager
  2. Switch to “Available Plugins” tab
  3. Select the “BlazeMeter Step-by-Step Debugger”
  4. Click “Apply Changes and Restart JMeter”

Once JMeter will relaunch itself, you should see the debugger plugin under “Installed plugins”.

JMeter Step-by-Step Debugger

Now, let’s go for a short tour to use it. For that, I’ve prepared a JMX file (attached) as an example in order to show you how to use the debugger features.

Features of the Step-by-Step JMeter Debugger

Feature 1: Running your Script Using the Debugger

  1. Go to Run-> Step by Step Debugger
  2. Maximize the pop-up window and click the “Start” button at the upper right corner
  3. You probably noticed that:
    1. Sample #1 is highlighted in Blue
    2. General Constant Timer is now in focus

This is because the debugger follows the JMeter scoping rules, which means execute the timer and then execute the sample. The debugger will always focus on the next element to be executed.

Feature 2: Step by Step: Let’s See These Variables!

  1. Press the “Step Over” button
  2. You probably noticed that the focus just switched to Sampler #1
  3. By pressing another “Step Over”, you will move to the Regular Expression execution
  4. Another “Step Over” will bring us to the “View Results Tree”
  5. Since the RegEx has been evaluated, you can see in the Variables tab that “RegExResponse” is now containing the string yada yada yada

JMeter Step-by-Step Debugger

Feature 3: Stop Before and After Listener Executions

You might be wondering what will happen in the next “Step Over”. Let’s find out.

Click it again.

You might have noticed that we are still in the “View Results Tree” listener even though it has been executed. Why?

Well, it’s not a bug. We just figured out that you will probably want to see the results before moving to the next element. So we might not want to switch the focus to sample #2 just yet.

Fun, ha… :)

(We would also remove any disabled elements—just to make your script cleaner while you debug it.)

Feature 4: Breakpoints

Just like any other IDE, we have breakpoints, just to save you gazillions of “Step Over” clicks. Let’s put a breakpoint on “Sample #2” by right clicking on it and select “breakpoint”. Then close and reopen the debugger, and then click on the “Continue” button. The debugger has stopped at Sample #2, just before it’s starting to execute its scope.

Feature 5: Evaluate Things on the Fly

You know the feeling when you want to see the value of a variable/function and monitor when it has been changed? Meet the Evaluate tab.

  1. Let’s restart the debugger from scratch and put a breakpoint on the RegEx2 element (under sample #2)
  2. Now before pressing “Continue”, let’s go to the Evaluate tab and put our #RegEx variable name (RegExTimestamp) in the JMeter expression line.
  3. Press “Continue” and wait for the debugger to stop before executing the RegEx
  4. You may notice that the value of the JMeter expression ${RegExTimestamp} is the string ${RegExTimestamp}. This is because JMeter has yet to initialize that parameter
  5. By pressing “Step Over”, you will cause JMeter to initiate this JMeter variable and now the Evaluate tab will show the variable value (see image below)
  6. You can use the “Step Over” over and over and on each time, the debugger will reevaluate that string for you

JMeter Step by Step Debugger

Next Steps / On Our Roadmap

  • We are going to add a stop button so you won’t need to close the debugger to restart your debugging session.
  • We are also going to mark any variable which just changed in Bold so it will be easier to recognize which variable just changed.
  • Improving the breakpoints stop on scope (and not the sampler).
  • Keyboard shortcut to open the debugger (we will do our best :) ).

To conclude - the Step-by-Step debugger is a significant tool which every JMeter scripter should have in their toolbox. In addition to debugging your scripts, you can also understand how JMeter scoping works and see, for the first time, the execution order of your test plan.

MongoDB Atlas is the easiest way to run the fastest-growing database for modern applications — no installation, setup, or configuration required. Easily live migrate an existing workload or start with 512MB of storage for free.

java ,jmeter ,debuggers ,blazemeter

Published at DZone with permission of Refael_Botbol, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}