1
votes

I'm having trouble with the If Controller in jMeter.

I have a thread group. Inside the thread group is a loop controller. Each time the loop executes, it runs an HTTP sampler.

I want to trigger the If Controller based on the response of this sampler.

However, the If Controller only seems to trigger if it contains another sampler.

But I don't want it to contain a sampler. The steps to be executed when it triggers are a JSON Path Extractor and a Beanshell PostProcessor. These are used to extract part of the JSON in the response from the existing sampler and then use this value to update a shared hashmap in the Beanshell PostProcessor. But they won't run without a sampler present inside the If Controller. And if I put a sampler in there, of any description - even a dummy one, the response data from the first sampler is lost and I can't get to the JSON response from it any more - and the test is then broken.

Any idea how to get round it?

I've tried adding blank listeners and things like that but they don't cause the If Controller to trigger. The only thing that does is a sampler which then breaks my test sequence.

An If Controller is not allowed as a child of the first sampler.

1

1 Answers

1
votes

Yes, the jmeter internals work only with samplers. So to run a post-processor in some scope (your IF controller creates the scope), you need a sampler inside it. All the post-processors/timers/listeners etc are actually attached to the samplers of their scope. It is important thing to know about JMeter.

To achieve your goal, you can do a trick where you attach the Regexp extractor to the main sampler and extract all response body to some variable. Then add a dummy sampler and put that variable as the response body. Now you will have the information passed to your extractors within the scope.