Functional Testing 06: Getting Started with Debugging Your Tests

Sixth in a series focusing on using JMeter for functional testing of an API.

Unlike every software developer I have ever known, I make mistakes. And you will too, especially as you begin creating more and more complex tests. And when you see your tests doing things you don’t expect (or not doing things you do expect) it helps to know how to go about debugging the problem.

So, let’s take a break from building our tests and learn about a couple of the ways we can poke at JMeter to figure what’s going wrong when things don’t work.

Before we begin make sure you have the test plan from the previous tutorial or download this one to use.

In this tutorial we will touch on two different ways for debugging what is happening using the Debug Sampler and the JMeter log file.

Functional Testing 06: Getting Started with Debugging Your Tests

  1. Open the test plan
  2. One of the best and easiest to use methods of debugging your tests is to use the Debug Sampler. The Debug Sampler allows you view the values of all the variables in a thread at the time the Debug Sampler is run. It is especially useful when you are using Loop or While Controllers and variable values will change behind the scenes. Let’s see how we can use a Debug Controller in our Signin tests.
  3. Right-click on the While Controller and select Add > Sampler > Debug Sampler
  4. Run your tests again and you should see one instance of the Debug Sampler for each iteration through the While loop.
  5. Click on a Debug Sampler in the View Results Tree then select the Response data tab. At the bottom you’ll see the three variables we are using for the test and their current value when the Debug Sampler was encountered.
  6. Click on each Debug sampler and you’ll see the values change. If we were experiencing problems with our Signin tests the Debug sampler could help us see what might be going wrong with our variable values.
  7. Next we’ll see how we can use the JMeter log to look for any errors.
  8. Select the CSV Dats Set Config and remove the “c” from the beginning of credentials.csv. This will cause the credentials file to not be found when we run our tests.
  9. Run the test again.
  10. You’ll notice that only the Info test is run. In the top right corner of the dialog you’ll see an alert icon with a red 1 next to it. Click the alert icon to unhide the log at the bottom of the dialog.
  11. Looking at the log info we can see an error indicating that redentials.csv cannot be found.

There we have it. Pretty easy right? We can now use Debug Samplers and the JMeter log to give us information about what is happening when things go wrong.

Before you close your test plan be sure to:

  1. Right-click the Debug Sampler and selct Disable
  2. Set the CAV Data Set Config back to use credentials.csv


Tutorial Test Plan

Leave a Reply

Your email address will not be published. Required fields are marked *