Reputation: 569
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
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.
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.
I hope this will help.
Upvotes: 0