Forum Discussion

Prudential_UK_A's avatar
Prudential_UK_A
Frequent Contributor
16 years ago

Problem with assertions running twice

Hi,
We've noticed that when we run a testcase or testsuite or project, the assertion on requests actually run twice.
When the request is run by itself, it runs the assertion once only.
I have made an example project to demonstrate this, with a script assertion that puts a single line in the log. It is attached.
Regards
Peter

1 Reply

  • Hello,

    This happens if you run a TestCase (or TestSuite, etc ) while the Request window is open. The assertions will then run twice. Once for the TestCase runner and once to display the results in the open Request window. If this causes a problem for you, please run the TestCase (or Suite or Project) with the Desktop panel for the Request closed. If you need to ensure that an assertion is only run once per "run" you could add this groovy snippet to the beginning of the assertion (only works for Script Assertions):


    if(!context[this.toString()]) {
    context[this.toString()] = true
    return
    }


    The above snippet will cause the assertion to stop executing if it has already been executed once in the current context. Note that if the Request is executed more than once, the Assertion will still only be run once.

    Regards,
    Dain
    eviware.com