Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JMeter Response assertion fails

I'm getting assertion failure even if the response are correct. But it saying something about expected "/", Before and after the html code. Why is that?

Apply to: Main sample only
Response Field to Test: Text Response
Pattern Matching Rules: Contains

Patterns to test: < html>
< body>
< h1>Flight request - 5< /h1>
< p>Departure airport code: GBG< /p>
< p>arrivalAirportCode: STM< /p>
< p>No of passengers: 12< /p>
< p>Status: CREATED< /p>
< /body>
< /html>

Response:

< html>
< body>
< h1>Flight request - 5< /h1>
< p>Departure airport code: GBG< /p>
< p>arrivalAirportCode: STM< /p>
< p>No of passengers: 12< /p>
< p>Status: CREATED< /p>
< /body>
< /html>

Assertion failure message: Test failed: text expected to contain /< html>
< body>
< h1>Flight request - 5< /h1>
< p>Departure airport code: GBG< /p>
< p>arrivalAirportCode: STM< /p>
< p>No of passengers: 12< /p>
< p>Status: CREATED< /p>
< /body>
< /html>/

like image 819
Henrik Avatar asked Apr 18 '26 20:04

Henrik


2 Answers

I solved it by creating more "patterns to test" and to have only a single row in each "pattern to test." which it is compared. Probably it was a "invisible" whitespace or something else.

like image 141
Henrik Avatar answered Apr 22 '26 04:04

Henrik


This is because JMeter internally uses a regular expression when you choose Contains or Matches pattern matching rules. Try to use the equals rule if possible, but be mindful of line breaks and white space characters that visually not be different but actually are.

More info: http://jmeter.apache.org/usermanual/component_reference.html#Response_Assertion

like image 40
PålOliver Avatar answered Apr 22 '26 06:04

PålOliver



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!