Thursday 20 March 2014

What are Pre-Processor and Post-Processor elements? In what order does JMeter process various type of elements?

 A Pre-Processor executes some action prior to a Sampler Request being made. If a Pre-Processor is attached to a Sampler element, then it will execute just prior to that sampler element running. A Pre-Processor is most often used to modify the settings of a Sample Request just before it runs, or to update variables that aren't extracted from response text.


A Post-Processor executes some action after a Sampler Request has been made. If a Post-Processor is attached to a Sampler element, then it will execute just after that sampler element runs. A Post-Processor is most often used to process the response data, often to extract values from it.

A Regular Expression Extractor can be used as a Post-Processor element to extract values to be used elsewhere in subsequent requests. For example, if you are using JSF and Seam frameworks, the jsfViewStateand CID values can be extracted as shown below:






The elements are executed in the following order as per the JMeter documentation.

0. Configuration elements
1. Pre-Processors
2. Timers
3. Sampler
4. Post-Processors (unless SampleResult is null) 
5. Assertions (unless SampleResult is null) 
6. Listeners (unless SampleResult is null)

Timers, Assertions, Pre- and Post-Processors are only processed if there is a sampler to which they apply. Logic Controllers and Samplers are processed in the order in which they appear in the tree. Other test elements are processed according to the scope in which they are found, and the type of test element.

No comments: