Forum Discussion

Manfred_F's avatar
Manfred_F
Regular Contributor
6 years ago
Solved

Evaluate dialog as calling context

How can a script procedure determinate, whether or not it was called from the context of the evaluate Dialog?

 

I added assertions to my Scripting Code, which do stop the test run under unexpected conditions. Using the evaluate/inspect function simply executes any function or property of an object variable having no Parameters, regardless of whether they should be executed in the given Situation or not, thus triggering my assertions.

 

Probably an existence check for the evaluate window would do the Job (should run fast..)?

7 Replies

  • Marsha_R's avatar
    Marsha_R
    Champion Level 3

    You could set a flag inside the evaluate/inspect function (on at the beginning and off at the end of it) and then if the assertions are triggered and the flag is set, write something to the log to indicate that assertions were called from that function.

     

     

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    Evaluate window/dialog?  You mean when debugging, you want to detect that code is executed through the Evaluate dialog in TestComplete?

     

    I'm not sure there's an easy built-in way to do so.  I'm not sure doing an "existance" of the dialog is the best idea... TestComplete is typically excluded from most object identification... it's kind of bootstrappy/circular reference to have TestComplete check for existance of itself... I suppose you could do it that way.

     

    Could you give an example of a function that you would call from the evaluate dialog?

    • Manfred_F's avatar
      Manfred_F
      Regular Contributor

      Well, here is the example.

       

      I set a breakpoint and let the script run to it. Then, I use the evaluate Dialog to Show variable values. In case my variable is an object variable, doing so will automatically execute any of the object's functions and properties having no Parameters to Show their results.

       

      If I put an Assertion into such a function/property to prevent it from being run under unexpected conditions, this Assertion will fire. And if I decided to stop the test in case of this firing Assertion, the test will be terminated, just because I used the evaluate window. :-(

      What I want to do now is to detect - Evaluation window yes or no - and if yes - let my Assertion not terminate the test but maybe just log a message.

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        Unfortunately, as mentioned, there's nothing specific in TestComplete that will prevent any code assertions to be skipped due to debugging activities using the Evaluate dialog.  You can try detecting if the dialog is present but, as mentioned, I'm not sure how well that will work.

         

        Have you tried using a Watch list item instead of the evaluate dialog?  That acts a bit differently on things, I think.  I'm assuming the object is a custom object you wrote in code and not an onscreen object.

        What code language are you using?  If you're using JScript or JavaScript, you can detect whether parameters were used in calling methods and determine, from that, if you should trigger the assertions.