Processor in JMeter is helpful in modifying the Samplers as per their choice.
In JMeter Processors are of two type,
- Pre-processor
- Post-processor
Pre-processor:
Pre-processor performs some task before building Sampler Request. Suppose, somebody wanted that JMeter to “spider” through website under test, parse link which find out all links on the page and return the HTML. Before creating an HTTP request, you have to add action “HTML link parser” to your controller.
Post-processor:
Post-processor performs some task after building Sampler Request. Suppose, using JMeter, user sends HTTP request to the web server “www.google.com” and get the response, under test. You will definitely like to stop the test, after getting response error by web server. To handle this situation, use post-processor, like this,
How Processor Works in JMeter?
Here you will get to know each and every step involved in creating Post-processor in JMeter. Before proceeding on this, first we should get to know that how to execute a simple test script,
First, using JMeter, user sends HTTP request to the web server “www.google.com”, under test.
Second, user gets response from the Google server.
Third, if server sends the response “error”, the test will be stopped by JMeter.
Fourth, if server sends the response “OK”, the test will be continued by JMeter.
To do further process on this example,
- Add Post-processor Element through Thread Group
- Add JMeter element
- Add Post-Processor Element
- Add Result view Tree
- Run the test
First step: Add Post-processor Element through Thread Group
To create the Thread Group, first run JMeter, from opened interface of JMeter choose Test Plan from the tree and right click to choose Add -> Threads (Users) ->Thread Group.
After opening thread Group, enter Thread Properties as shown in figure below,
In the above figure, Number of Threads: 10 numbers of users are connected to target website, Loop Count: execute testing 10 numbers of times, and Ramp-Up Period: 1.
According to this setting, 10 user requests sends to web site http://www.google.com 10 times.
Second Step: Add JMeter elements
In this article we will add,
- HTTP request Default element
- HTTP Request
To get this element, go to Thread Group and right-clicking, from context menu select Add –> Config Element -> HTTP Request Defaults.
In the HTTP Request Defaults page, enter the Website name (www.Google.com) under Web server -> Server name or IP.
HTTP Request:
To get this element, go to Thread Group and right-clicking, from context menu select Add -> Sampler -> HTTP Request.
“Path” field in HTTP Request page shows that which URL request you need to direct to Google server like: enter “abcd” text in Path field. JMeter will generate the URL request http://www.google.com/abcd (wrong URL request) to Google server. If you leave the Path field blank, will URL request will be http://www.google.com.
Third Step: Add Post-Processor Element
To add Post-Processor Element, right click on Thread Group -> Add -> Post Processor -> Result Status Action Handler permits user to stop the thread or the whole test whenever user request get fail.
The following figure shows “Result Status Action Handler” pane. From “Result Status Action Handle” choose “Stop Test Now”. This selection will stop the test if JMeter get the error from server response.
Fourth Step: Add View Result Tree
To open result tree, right click on Thread Group -> Add -> Listener -> View Result Tree, shown in the given below figure,
Fifth Step: Run the Test
In View Result Tree pane, press on Run button on Menu bar to see the result. It will display error message, sent by Google server and the test will stop.
Conclusion:
In today JMeter Tutorials Series Day 9, we have seen what all different types of Processors used in JMeter. We hope this list comes in handy to you when in look for a JMeter processors. If want to add your experience on processors then let our readers know in comments below.
Don’t Miss Another Article
Join over 10,000 people who get FREE and fresh content from this Blog.
We Respect Privacy, You’re Safe! No Spam!