Forum Discussion

mcbootus's avatar
mcbootus
Contributor
14 years ago

[R]Batch Script Continues When Assertion Fails In a Testcase

Dear Support,

I have a master batch script which calls many test cases in sequence using this code:


// <eventlist>
def eventlist = project.testSuites['E-GREFFE XML STRUCTURE'].testCases['eventList'].run( null, true )
eventlist.waitUntilFinished()

// <procedureIdentification>
def procedureIdentification = project.testSuites['E-GREFFE XML STRUCTURE'].testCases['procedureIdentification'].run( null, true )
procedureIdentification.waitUntilFinished()

// <tfueArticleList>
def tfueArticleList = project.testSuites['E-GREFFE XML STRUCTURE'].testCases['tfueArticleList'].run( null, true )
tfueArticleList.waitUntilFinished()

// <securityInfo>
def securityInfo = project.testSuites['E-GREFFE XML STRUCTURE'].testCases['securityInfo'].run( null, true )
securityInfo.waitUntilFinished()

etc .....................



Each test case contains many assertions but when any assertions fail the batch script continues to run all the tests, even if a particular test case partially completed a testcase due to an assertion failure.

I have checked the setting "Fail on error" in the batch script and each test case being called by the batch script but this does not seem to stop the test when an assertion fails.

Thank you in advance.
Armen
  • Hi!

    you need to manually check in your code if the testCase has failed and abort execution if so. I.e. add the following:

    // <eventlist>
    def eventlist = project.testSuites['E-GREFFE XML STRUCTURE'].testCases['eventList'].run( null, true )
    eventlist.waitUntilFinished()
    if( eventlist.status.toString() == "FAILED" )
    throw new Exception( "eventList TestCase failed with message [" + eventlist.reason + "]" )

    etc...

    Hope this helps

    regards,

    /Ole
    eviware.com
  • Dear Ole,

    Perfect - works really well. Thanks again for your great support!

    Best regards,

    Armen