Forum Discussion

scambias's avatar
scambias
Contributor
8 years ago

Is it possible to debug (breakpoints, watch vars) scripts belonging to script extentions?

Hi,

 

I need to debug the source code I wrote for a script extention (in vbscript).

I followed the hints suggested here:

https://support.smartbear.com/testcomplete/docs/working-with/extending/script/debugging.html

and here:

https://support.smartbear.com/testcomplete/docs/working-with/extending/script/creating/basic.html#BestPractices

 

but did not succeed to put some breakpoints and get the debug stop there.

Thank you very much!

7 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    Once the extension is encapsulated into the TCX file and "consumed" by test complete, you don't have any debugging capabilities of it.

     

    What I do is I have a separate TC project where I do all my script extension development and test out my methods and objects using the debugger built into TC that way.  

    • scambias's avatar
      scambias
      Contributor

      You mean that (even if unpacked) if the source code is "loaded" as a script extension it is not possible to debug it, whereas I need to use that code as just simple vbscript code  (added as script in the test project) and then tested by calling single functions?!

    • tristaanogre's avatar
      tristaanogre
      Esteemed Contributor

      REading the help topic you referenced on this... In this case, "debugging" is a coding act, not a tool function.  To "debug" code, in the days before IDE's that have a lot of bells and whistles, you would run your code, look for errors, fix them, rerun, etc.  You would add specific code into your application you're debugging to do logging, etc., as you're running to be able to determine what is going on.

       

      I just tried... and no, break points don't work.  And, again, I can kind of understand why.  While the extension is not encapsulated as a TCX, it is, in a way, "compiled" into TestComplete.  There's a thread (or threads) in TestCOmplete that run the code in the extensions... the debugging of scripts with breakpoints and such are in a different thread entirely.

      Now... I agree, it would be nice to have the breakpoints and such work.  Feel free to make it a feature request and, when you do, I'll vote it up.  But, in the meantime, what you're doing will work just fine, you'll just need to get a little more down and dirty in your code to figure out what problems you may be having.  Add logging statements to expose variable values, code conditions, etc and then, after you run something, go back and check again.

       

      If you truly want to use the breakpoints... then yes, you'll need to create some sort of test harness to test the functions of your script extension.  

      • scambias's avatar
        scambias
        Contributor

        ok, thank you.

        Yes, this actually should be a good (nearly expected) improvement.

        I am surprises I am the first one who discovered this... honestly. When people write script extentions are they so good they don't make any mistake so they don't need to debug (real-time) as well as the other kind of scripts?

        Debug scripts by log.messages brings me back to early 90s, which is something I did for a loooong time!

        But I must be really bad on that!!! LOL

         

        Anyway, we'll do our best to test the single routines in a separated script and eventually pack them into a script extension object.

        Thank you very much.

  • I did not encapsulate the source code yet.

    According to the page (https://support.smartbear.com/testcomplete/docs/working-with/extending/script/debugging.html):

     

    Note, however, that debugging packaged extensions (.tcx files) is not possible, because TestComplete locks them when it is running, so you will be unable to update the extension file without leaving TestComplete. This problem does not apply to unpacked script extensions.

     

     

    But I still cannot debug it with unpacked. why?