Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to stop thread If response assertion fails in Jmeter

Tags:

jmeter

I want to implement error handling in my script (like textcheck in LR).

I’m able to validate the Text using Response Assertion.

But my question is how to stop the thread if the Response Assertion (text check) fails.

like image 263
Loyo Fernando Avatar asked Sep 25 '12 09:09

Loyo Fernando


People also ask

How do I stop a thread in JMeter?

JMeter does not provide a way for stopping thread to execute a "shutdown sequence", they have tearDown Thread group instead. You should use it in your case.

What is response code in JMeter?

Response Code: JMeter checks and validates the response code only like 200, 302 etc. Response Message: JMeter checks and validates the response message only like OK, Error etc. Document (text): This option allows JMeter to search the pattern string in the document returned by the server.

What is JSR223 assertion in JMeter?

The code-based assertion like BeanShell, JSR223, BSF doesn't have a GUI component that identifies the scope. So it signifies that the user should implement all the assertion logic and scope manually. An assertion in JMeter can be applied to all level samples both in a greater and lower scope.


2 Answers

In Thread group, choose Stop Thread under Action to be taken after a sample error. This will stop the test once assertion fails

like image 144
user1696977 Avatar answered Oct 12 '22 00:10

user1696977


If you need to limit this behaviour to one request, add a Result Status Action Handler as a child of the request, then set it to Stop Thread

like image 34
Joseph Moore Avatar answered Oct 12 '22 01:10

Joseph Moore