Forum Discussion

Philip_Baird's avatar
Philip_Baird
Community Expert
12 years ago

Cannot debug Script Extensions in debugger

Hi all, I am hoping someone can help me, I am attempting to debug a Script Extension following the guide here




I have got the Script Extension installed unpacked and am able to make changes to the source, e.g. insert Log,Message() etc.


 


I have also added the source js file to my Project as an existing item


 


The problem I have now is I cannot actually debug the code in the debugger, I have tried


1. Stepping into functions in the Script Extension


2. Setting breakpoints in the source js file


 


all to no avail, the debugger simply steps over function calls to the Script Extension and continues on it's merry way until, in this case, it crashes.


 


The documentation states "Note, that you can also debug the source scripts of the extension directly in TestComplete, just like you debug ordinary test scripts" which implies what I am attempting is possible, my results, however, seem to indicate this is false.


 


Is it possible to have Script Extensions run in the debugger?


If so, how? the documentation isn't really of much help.


 


Regards,


Phil Baird

3 Replies

  • I debug my script extensions as ordinary script units: supposing that all libraries are .js files, I just added them as existing items into project.



    All my units contain testing functions (which are not exposed in script extensions) but this functions call other functions which need to be tested directly (not using script extension notation).



    When an unit gets debugged, I click Save button and reload script extensions.



  • Philip_Baird's avatar
    Philip_Baird
    Community Expert

    Hi Andrey, I normally work in the way you describe.


     


    Unfortunately, the case I currently have, I have an error that only manifests itself when code is being executed within the confines of a Test Extension. If I call the code directly from the source Script Unit using //USEUNIT etc. the code runs fine, hence my need to debug the Script Extension directly.


     


    Phil


  • Sorry if my finding is not what you're looking for: I tried to implement intercepting technique for debugging which redirects control back to TC units.


     


    at the beginning of script extension unit I defined variable


     


    debugON = true;


     


    at the beginning of each function I inserted line of code:


     


    function myCode( param1, param2 )


    {


      if ( debugON && typeof KeywordTests == "undefined" ) return Runner.CallMethod( "myUnit.myCode", param1, param2 );


      [...]


    }


     


    myUnit is name of actual unit (myUnit.js)


     


    I check KeywordTests object to avoid endless recursion after entering into unit (this object is not available in script extensions).


     


    If you have error specifically related to script extensions (availability of certain script extension objects etc.) this method will definitely fail.