16

I have been using JMeter for a while and only for load tests. I was wondering if I can use it for ordinary functionality testing.

For example: I have a malformed XML and an application returns 400 Bad Request which I expect to be returned - so it's correct but JMeter resolves it as a failure.

I tried Response Assertions but it didn't work...

Is this possible with JMeter?

user219882
  • 15,274
  • 23
  • 93
  • 138

2 Answers2

53

To test a non 200 response code, you must check the 'Ignore Status' field in the Response Assertion. Without this, the test will always fail regardless of the response assertion.

So here is what you need to do to test the http response code 400:

Add a new Response Assertion. Set the following assertion properties:

  • check the 'Response Code' radio button.
  • check the 'Ignore Status' box.
  • check the 'Equals' radio button in the Pattern Matching Rules.
  • click the 'Add' button.
  • enter '400' in the row in Patterns to Test.

Done.

toconn
  • 804
  • 6
  • 15
  • 1
    Or you could: check-on the "Matches" radio button in the "Pattern Matching Rules"; click the 'Add' button; and fill in the "4.." regEx matching pattern into the row in "Patterns to Test". ... to accept whichever 4xx response-code as "passed", for any "user's bad request" in general. – Franta Sep 18 '17 at 11:12
6

Easily.
See answers to this.

You can also possibly try NOT check-box in Pattern Matching Rules Response Assertion.

Community
  • 1
  • 1
Aliaksandr Belik
  • 12,725
  • 6
  • 64
  • 90