cancel
Showing results for 
Search instead for 
Did you mean: 

Assertion Question

Highlighted
Super Contributor

Assertion Question

Hello,
I guess I am the only one to ask questions in the this forum
I have question about assertions.  Below is part of a response from my web services.


                2211
                                CustomGrid_InvalidCustomGridNameFormat
               



                  2203
                 
                  NPE
                 



In the response message I expect only ErrorCode-->2211 so I have an XpathMatch assertion for that. However, as you can see in the response above, I got more than one ErrorCode which is not the expected behavior of my web service. There should only have been one error code.

Is there a way I can catch this kind of error through some assertion.

Thanks

Ali
4 REPLIES 4
Highlighted
Super Contributor

Hi!

sure, add an xpath assertion containing

count( //ErrorCode )

and set the expected value to 1

or you can set the xpath expression to

count( //ErrorCode ) = 1

and set the expected value to

true

Hope this helps!

regards,

/Ole
eviware.com
Highlighted
Super Contributor

Ole,
I added count(//Error) under 'Xpath Expression' and '1' under 'Expected Results. When I press 'Test' I get

XpathContains assertion failed for path[count(//Error)]:comparisonFailure:expected:<1> but was:<0>

Shouldn't I get
....but was:<2>
since i have 2 errors in the response.

Thanks

Ali
Highlighted
Super Contributor

Hi Ali,

maybe you need a namespace prefix, can you show the entire message? Alternatively, go to the outline editor for the response, right-click on the Error node and select "Add Assertion -> For Count", which should create the correct xpath expression for you.. (see http://www.soapui.org/userguide/functio ... ion_Wizard)

regards,

/Ole
eviware.com
Highlighted
Super Contributor

Thanks for the quick response Ole. I wasnt aware of the assertion wizard. Example works now

- Ali
New Here?
Join us and watch the welcome video:
Announcements
TechCorner Leaderboard
Want a fun and easy way to learn ReadyAPI and show off your skills? Try solving weekly TechCorner challenges and get into the Leaderboard!


Challenge Status

Get a full Raw JMS request

Participate!

Compare an expected JSON value and actual response in Events

Participate!

Fetch value/data from JSON response using Groovy Script

See replies!

Get data from Petstore and add it to Excel sheets

Participate!
Top Kudoed Authors