0
votes

I have a Thread Group wherein I have three samplers. They are HTML Requests. The first one returns a person and gives me the name, age and address. The second one changes the attribute name of the person but has no response. The third sampler is the same as the first.

The second sampler isn't working and doesn't change the name.

I want a failure message like: "The name of the person was $(name1) and should be changed to $(name2), but the name is $(name3)" or something like that.

I do the whole things with Groovy so is there any way to generate variables with the output of the first and third request and the input of the second?

2

2 Answers

0
votes

Most probably you're looking for Response Assertion, you can conditionally mark samplers as failed depending on various criteria. It might be the case that you won't even need scripting like.

Just add Response Assertion as a child of 3rd request and configure it to expect ${name3} variable to be present in the response (you can use Perl-5 style regular expressions for this as well) and if the name will not be present - the sampler will get failed and you will see the relevant failure message

JMeter Response Assertion

More information: How to Use JMeter Assertions in Three Easy Steps

0
votes

I do not think you can do it the way you describe it, because samplers are processed sequentially, so you can not process first, third and go to second request. You might want to re-evaluate your approach.