Ghost
Ghost

Reputation: 569

Jmeter using Response assertion for conditional case

I have a test case which restricts a user to have access to several accounts except what she is assigned to (say only Account-X) . So I use HTTP Request to get Accounts. The results are successful (200 code), I need to examine response data, if data contains other accounts (which that user is not assigned to) then mark that test failure. I have been usign Bean post shell as such: (where Z2 is Account-X and matches is number of accounts in response data)

if ( (prev.getResponseDataAsString().indexOf(Z2) >= 0) || (matches > 1) 

I am told I should have used Response assertion,

Field to test : Text Response,

Pattern matching rules : Equals (not sure of this)

what should I set my "Pattern to Test" then?

Upvotes: 0

Views: 236

Answers (1)

sunny_teo
sunny_teo

Reputation: 1999

Considering your response may contain account X,Y and Z. You can use response assertion and put Account Y and Account Z in pattern test as shown in the below image.

In pattern matching rules select "Contains" and "Not" check. Not check will reverse the assertion.

enter image description here

Below you can see if response contain y or z along with x then request will fail and if only account-x is present then it will pass.

enter image description here

I hope this will help.

Upvotes: 0

Related Questions