Forum Discussion

jorgesimoes1983's avatar
Regular Contributor
9 years ago

Clear breakpoints by script

Hi all! Sometimes I run my project and forget to clear breakpoints, is there any way to clear it by script?


For example, I would like to clear all breakpoints by doing something like this:


function clearBreakpoints(){

   // clear breakpoints magic




18 Replies

  • william_roe's avatar
    Super Contributor

    You can disable all debugging from the toolbar without having to find all breakpoints. The included image shows debugging enabled. Each click toggles debuggin.


    disable debugging.JPG

    • jorgesimoes1983's avatar
      Regular Contributor


  • Bit of a long winded way with additional work that is essentially mimicking the toolbar button but what about using conditional breakpoints and a debugging flag?


    Have a variable, something like enableDebugging and set it to true by default. When adding a breakpoint put enableDebugging in the condition column. When it's true it will pause on breakpoints, when it's false it will ignore it and continue running. 


    You can then have a SetDebuggingMode function that sets this to true/false and call it as required. 






    • jorgesimoes1983's avatar
      Regular Contributor

      StevenN, that is actually a good idea, but how do you disable debugging by script (without having to press the button)?



      • StevenN's avatar

        So, if the project variable was called "enableDebugging", The set function could be:


        funtion SetDebuggingMode(state)


           pSuite["debuggingMode"] = state;



        Then when running your tests have something like this:


        function RunMainTests()


          // Sets the flag to false so any breakpoints will be ignored


          // Run tests...



  • NOTE: Backup your project before you try this, just in case.


    Haven't got time to test this myself, but I believe the breakpoints are stored in the project suite .tcCfgExtender file. 


    I think this file is generated and not required to run your tests. So you could try to delete this before you run.


  • HKosova's avatar
    SmartBear Alumni (Retired)

    You can add and delete breakpoints only at design time.


    To delete all breakpoints:

    1. View > Debug > Breakpoints.
    2. Ctrl+A, Del.

    Or you can temporarily disable the debugger: in the Debug menu, unselect Enable Debugging. The breakpoints remain, but TestComplete won't stop on them.