JMeter Tutorials

Graph Results Listener Example

In JMeter there are number of listeners available in order to monitor and analyse the results in different parameters and statistics. We need to add an appropriate listener to analyse results which is difficult part of the performance testing. In the below example we will add 'Graph Result' listener. Graph Results listener presents data, average, median, deviation and throughput in a graphical format.

Please do not use listeners during the load test as it consume loads of resources and produce unreliable load test results. You can use when developing and debugging tests.

Listeners in JMeter

Listeners facilitates viewers to view responses generated by samplers in the form of tables, graphs, trees or simple text in some log files and also give pictorial access to the data collected by JMeter about those test cases as a Sampler component of JMeter is executed.

To view the details of sampler requests and responses, add either "View Results Tree" or "View Results in table" Listeners to a test plan which displays basic HTML and XML representations of the response. To view the response time graphically, add Graph Results which plots the response times on a graph.

JMeter Post-Processors with Example

A Post-Processor elements is executed after the sampler and can be used for post condition response. If a Pre-Processor is added to a test plan, then it will be executed after response has arrived. A Post-Processor is often used to find out something from response for some actions. These action may be some time to validate response or to extract something and process.

Here is a list of available Post-Processors in JMeter:

JMeter Pre-Processors with Example

"Pre-Processors executes some action just prior to a sample being run".

A Pre-Processor elements is executed before the sampler and can be used for precondition setup. If a Pre-Processor is added to a test plan, then it will execute just before to that sampler element running. A Pre-Processor is most often used to adjust the settings of a Sample Request just before it runs.

JMeter Duration Assertion with Example

This assertion tests that each response was received within a given amount of time. Any response that takes longer than the given number of time (milliseconds) specified by the user is marked as a failed response.

Let us look into an example :

Step 1. Right Click Test Plan > Add > Threads(Users) > Thread Group

Step 2. Thread Group > Add > Config Element > HTTP Request Default
Set Server Name as:

Step 3. Thread Group>Add > Sampler > HTTP Request (Change name to Google Home Page)
Set Path as: /

Assertions in JMeter examples

Assertion helps to confirm that server under test returns the expected result. Assertions allows us to define the pass/fail criteria for application under test. We can configure what kind of assertions is active for every test plan.

Example, if a web response doesn't contain an expected expression, it would be considered as a failure.

Assertions can be added to any controller in a test plan by simply right-click on the controller and add an assertion. Assertions can be applied to a main sample and its sub-samples, or only to sub-samples.

JMeter Timers - Constant timer Example

Timers are used to define the time period that you want to wait between requests. If you do not specify any, JMeter will execute the next request immediately after the current one is finished, without any waiting time.

By default, a JMeter thread sends requests without pausing between each request. It is recommend that to specify a delay by adding one of the available timers to the Thread Group. These timers will cause JMeter to delay a certain amount of time before each request that a thread makes.

Logic Controllers - JMeter loop controller example

Logic Controllers let you customize the logic that JMeter uses to decide when to send requests. A Logic Controller can changes the order of requests that come from its child elements. The child elements of a Logic Controller may comprise Samplers, Configuration Elements, and more Logic Controllers. For these requests, JMeter may randomly select (using Random Controller), repeat (using Loop Controller), interchange (using Interleave Controller) etc.

Logic Controllers determine the order in which Samplers are processed

JMeter HTTP Request Sampler Example

In the previous tutorial, we have seen some basic information on sampler. Here we will try to understand in detail about most commonly used sample which is HTTP Request sampler with example.

Let us now create a plan to test an web page using HTTP Request Sampler. This sampler lets us to send an HTTP/HTTPS request to a web server. If we want to send multiple requests to the same web server, we should consider using an HTTP Request Defaults Configuration Element so that we do not have to enter the same information for each HTTP Request.