đź““
Loadium Wiki
  • Welcome to Loadium
  • Getting Started with Loadium
  • Quick Guides
    • Quick Start
    • JMeter Test
    • Locust Test
    • Script Builder
      • Simple HTTP Builder
      • Record&Play
    • Gatling Test
    • WebDriver Test
    • HLS Test
    • Understanding Test Reports
    • Test Execution Fail Reasons
    • File Output
  • ABOUT LOADIUM
    • Features
    • Pricing
    • VUH - Virtual User Hour
  • ACCOUNT
    • Profile & Account
    • Subscription
  • Features
    • Test Report
    • Compare Test
    • Private Location
    • Report PDF Export
  • Test Settings
    • Split CSV
    • Sandbox
    • Multi-Step
    • Geolocation
    • Customize Setup
    • Dedicated IP
    • Send Email
    • DNS Override
    • TPS
    • Network Type
    • Test Scheduling
    • Test Failure Settings
    • JMeter Settings
    • Failure Criteria
    • Flexible Thread Scheduling
  • CONTINUOUS INTEGRATION SUPPORT
    • Azure DevOps Pipeline
    • Jenkins Load Testing with Loadium
  • Integrations
    • Microsoft Teams Integration
    • New Relic Integration
    • AppDynamics Integration
    • TeamCity Integration
  • Jmeter Corner
    • Built-in JMeter Functions
    • How to Install JMeter Plugins
    • Record and Play Load Testing With Jmeter in 5 Steps
    • Websocket with Apache JMeter
    • JMeter Timers
    • Handling Error Messages of JMeter Tests in Loadium
    • Details of Throughput Controller in JMeter (Splitting Threads to Different Requests)
    • How to Add a Varying Number of Parameters in Apache JMeter
    • Local Network Simulation On JMeter
    • Running Load Test with FTP Server
  • Gatling Corner
    • Introduction to Gatling
    • Gatling Recorder
    • Gatling Pros&Cons
  • PUBLIC APIs
    • Get Test Status Service
    • Authentication Service
    • Get Performance Test List Service
    • Start Performance Test Service
Powered by GitBook
On this page
  • Jmeter Functions
  • Example Case

Was this helpful?

  1. Jmeter Corner

Handling Error Messages of JMeter Tests in Loadium

PreviousJMeter TimersNextDetails of Throughput Controller in JMeter (Splitting Threads to Different Requests)

Last updated 3 years ago

Was this helpful?

Errors found during is a part of the process, are done to find them after all. After finding an error, understanding its reason is crucial. Some errors are easy to understand and recognize if they reveal themselves clearly, but sometimes errors are hard to detect and if their reason isn’t clear it might even lead to more confusing results.

There might be several reasons for an error to occur. It could be due to a logical error in the script, or while the script is doing its work properly, server might mess up when processing it.

Jmeter Functions

has a built-in functionality that allows us to handle error messages. Since is a Java application which is an OOP language, there is access to some objects that come in handy. One of them is the “Prev” class’ “prev” object that allows us to do workarounds for error messages, which you can find the complete documentation here:

Let’s take a look at some methods from this class:

  • getResponseCode() – Returns the last executed sample’s response code

  • setResponseCode() – Sets a custom response code to the last executed sample

  • getResponseDataAsString() – Returns the last executed sample’s response body

By using only these 3 methods, we can easily handle the error messages.

Example Case

Sometimes the message contained in the response code or the code itself isn’t self-explanatory enough. Likewise, there may be more detailed information of the error in the response body, and since what’s included in the body by default is not available to be seen in the report screen “Error” page, a configuration can be done to make it visible.

For example, the response error message “Internal Server Error” does not show the reason clearly, and if there is a possibility that its body contains information about the error, it is better for it to be shown here. For this, we can make a configuration in a JSR223 PostProcessor like the following:

And with the function:

if(prev.getResponseCode() == "500"){ prev.setResponseMessage(prev.getResponseDataAsString());

In Jmeter, instead of standart "Internal Server Error" message, we will get a message as shown below:

While in Loadium Report Screen, we will get the following result in Response Codes Page or Errors Page:

Happy testing!

If you don't see the answer to your question here, please to let us know! We're always improving our documentation.

JMeter Test
reach out to us
testing
tests
JMeter
JMeter
https://jmeter.apache.org/api/org/apache/jmeter/samplers/SampleResult.html