ASLA
ASLA

Reputation: 1

Jmeter: Ignoring certain parts of text in Response assertion

I'm using jMeter to check if certain text comes back from our testclient. I use a response assertion and have a pattern that I'd like the text response to contain.

An example:

'Blablablabla =test1 Blobloblo =2 url = /testest/doubletest/2014/testParam=123456789 blebleble=test blublublublu=23'

The value after testParam keeps changing every time the service is called, so the response assertion keeps giving an assertion failure.

Is there any escape character that can be used for larger pieces of text to ignore? \ only works for single characters. I tried things like .* and *, but they don't seem to work.

I can cut up the sentence in two parts to assert, but it's the combination of what is in front of the Parameter and after it that makes the check most valuable, so I'd really like it intact.

Upvotes: 0

Views: 2014

Answers (1)

Dmitri T
Dmitri T

Reputation: 168092

As per Response Assertion's documentation

The response assertion control panel lets you add pattern strings to be compared against various fields of the response. The pattern strings are:

Contains, Matches: Perl5-style regular expressions

Equals, Substring: plain text, case-sensitive

So you should be able to use regular expressions to filter out not interesting parts of the response.

  1. Change "Pattern Matching Rules" value to Contains or Matches

  2. Put the following condition into "Patterns To Test"

    'Blablablabla =test1 Blobloblo =2 url = /testest/doubletest/2014/testParam=(\d+) blebleble=test blublublublu=23'
    

This (\d+) will match any numeric value between testParam= and blebleble so any number change will be considered as pass.

For comprehensive information on using JMeter's Assertions refer to How to Use JMeter Assertions in 3 Easy Steps guide.

Upvotes: 1

Related Questions