Forum Discussion
Without getting into the nitty gritty details (which can be found here), an assert statement is like an assertion on a Soap/REST Test Step. It is verifying a certain piece of information and making the groovy test step pass or fail accordingly.
- richie8 years agoCommunity Hero
I gotcha - the groovy step will go 'red' if it fails - right?
I don't know if you noticed, but I had a second 'failed' option (VenueSyncIgnore as well as the VenueSyncError) within the cdata - I've altered your script as follows (totally ripping off what you've already done) and the results appear to work - script is below:
import com.eviware.soapui.support.XmlHolder def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context ); // get the response, specifically the //RETURN element that contains DATA tags. This may need to be adjusted to fit your own project, but you want to collect the //return element def response = context.expand( '${SOAP Request#Response#declare namespace NS1=\'urn:CSMVenueSyncServicesIntf-ICSMVenueSyncServices\'; //NS1:SyncVenueResponse[1]/return[1]}' ) // remove the CDATA tags response = response.replaceAll( "<!\\[CDATA\\[", "" ) response = response.replaceAll( "]]>", "" ) // Parse the response into XML def holder = groovyUtils.getXmlHolder( response ) log.info((holder["exists(//Responses/VenueSyncSuccesses/VenueSyncSuccess)"])); log.info(holder["count(//Responses/VenueSyncErrors/VenueSyncError)"]); log.info(holder["count(//Responses/VenueSyncIgnores/VenueSyncIgnore)"]); def successExists = (holder["exists(//Responses/VenueSyncSuccesses/VenueSyncSuccess)"]); def errorCount = (holder["count(//Responses/VenueSyncErrors/VenueSyncError)"]).toInteger(); def ignoreCount = (holder["count(//Responses/VenueSyncIgnores/VenueSyncIgnore)"]).toInteger(); assert (successExists && errorCount == 0 && ignoreCount ==0);
OK - if you're feeling in a helpful mood I have 1 more point and all I'll stand by all previous conversations
I need to be able to extract the VenueID attribute value from within the cdata string to pass this onto a subsequent JDBC test step. Essentially, once the successful request has been posted, I need to run a query to retrieve the record from within the DB to verify certain attributes have been updated.
I should highlight - the VenueID attribute will 'move' in the response, relative to whether the request is successful or is ignored (for certain error scenario) or is a failure (most severe failed options).
Obviously I only care about when the request has been successful as only successful requests will write to the DB.
I can extract the value and pass it onto the JDBC test step that'll be me very happy!
Cheers!
richie
- groovyguy8 years agoCommunity Hero
The first question I have is whether or not there will be more than one VenueID in the response, or if it will be singular? I can probably whip something up in a bit.
- richie8 years agoCommunity Hero
aaah - my whole SoapUI project got corrupted - I lost all msiadak's and Rao's good work!
if anyone gets the following warning "WARN:Test Monitor: Trying to unregister a non-existing test model item [model item ID" - in the ReadyAPI! Log - don't ignore it. I lost ALL my tests.
if you get this warning - do the following (sourced from https://community.smartbear.com/t5/SoapUI-Pro/Error-notifying-listener-before-run-ReadyAPI-1-8-0/td-p/126862)
1. On the SoapUI NG tab, double-click a project and check the "Compare" or "History" screen. Do you see the "Test Run History Disabled" message on them (see: http://screencast.com/t/eDWaD300USH)? If so, back up the DB, and then update it. Does this resolve the issue?
lesson to all (and me especially) backup all your stuff
groovyguy - YES - there is only 1 VenueID in any request. BTW - you'll be getting another email later on tonight with the correct details
Cheers to all!
richie
Related Content
- 4 years ago
- 3 years ago
- 6 months ago