I could be very wrong but I think that the problem is a logical one. If an assertion doesn't hold (if it fails), an exception will be thrown and the rest of the code won't be executed.
On Mon, Jan 11, 2016 at 8:20 PM, Deng, Lea <lea.d...@ccc.govt.nz> wrote: > I'm using Soap UI and Groovy Script to go through a xml response with many > Decision elements. > My Groovy Script refers to a DataSource 'Decision Exclusion List > RMA/2010/33789' for a list of exlusion text to search for in the xml > response. > I search for each DecisionCode read from the DataSource, then extract the > xml lines for this DecisionCode element, then look for the exlusion text > within them. > If the DecisionCode can not be found within the xml text, then I assert a > failure, and continue the loop. > However, the test does not continue. It stops after the failed assertion. > > Is that because "continue" does not work from within if { } ? > Thanks, > Lea > > Please see my code below: > > -------------------------------------------------- > > //(singleConsentString contains the xml text to search through) > > def exlusionList = testRunner.testCase.testSteps['Decision Exclusion List > RMA/2010/33789'] // refer to another DataSource test step to get a list of > exlusion text > > > def counter = 0 > while(exlusionList.next(testRunner,context)){ > counter ++ > log.info("counter for decision exlusion list: " + counter) > decisionCode = exlusionList.getPropertyValue('PathwayDecisionCode') > decisionDescription = > exlusionList.getPropertyValue('PathwayDecisionDescription') > > // search for the DecisionCode in xml text > int startIndexDecision = > singleConsentString.indexOf('<a:DecisionCode>'+decisionCode+'</a:DecisionCode>') > log.info('logging start index of Decision: ' + > startIndexDecision) > > // if DecisionCode is not found, assert a failure, and continue > the loop; > if (startIndexDecision < 0){ > log.info('Check Decision Code Failed because Pathway data > does not contain Decision Code: '+decisionCode) > assert startIndexDecision >= 0, "Failed because > "+decisionCode+" is not found in Pathway data, thus index is less than 0" > continue // this does not work > } > > // if DecisionCode is found, then extract the xml lines for this > DecisionCode, and check for DecisionDescription as well. > else { > String subStringDecision = > singleConsentString.substring(startIndexDecision) > int endIndexDecision = > subStringDecision.indexOf('</a:DecisionEntity>') > singleDecisionString = > subStringDecision.substring(0,endIndexDecision) > log.info('logging singe decision: '+ > singleDecisionString) > > assert singleDecisionString.contains(decisionCode)&& > singleConsentString.contains(decisionDescription) > } > } > > > ********************************************************************** > This electronic email and any files transmitted with it are intended > solely for the use of the individual or entity to whom they are addressed. > > The views expressed in this message are those of the individual sender > and may not necessarily reflect the views of the Christchurch City Council. > > If you are not the correct recipient of this email please advise the > sender and delete. > > Christchurch City Council > http://www.ccc.govt.nz > ********************************************************************** >