Forum Discussion

Awesome's avatar
Awesome
Frequent Contributor
17 years ago

deleting all assertions

hi all,

i have a groovy script which creates assertions for me.

at the beinging of the script i would like to 'initialize' the Assertions by deleting whatever is there and then run my create assertions.

how do i delete all assertions?

thanks!

4 Replies

  • AnandKiran's avatar
    AnandKiran
    Frequent Contributor
    Hi ,
            Can you please share me the groovy code which you have used for
    creating assertions which would be very help for me .

    Thanks
    With Regards
    Anand Kiran
  • Awesome's avatar
    Awesome
    Frequent Contributor
    sure thing:

    //Create Assertion Record Count
    assertCountText = "declare namespace ns1='xxxxx'; \n count( //aaa/bbb) \n"

    def assertion_count = testRunner.getTestCase().getTestStepByName(testStepName).addAssertion("XPath Match")

    assertion_count.name = "Check count of [Record]"
    assertion_count.path = assertCountText
    assertion_count.expectedContent = TheExpectedNumberOfRecords
  • Hello,


    def testStep = testRunner.testCase.testSteps[testStepName]
    for(def i=testStep.assertionCount-1; i>=0; i--) {
      testStep.removeAssertion(testStep.getAssertionAt(i));
    }


    This should work..

    robert