Re: Saving breakpoints
- From: "Ralph" <nt_consulting64@xxxxxxxxx>
- Date: Fri, 26 Sep 2008 11:10:14 -0500
<asperamanca@xxxxxxxxx> wrote in message
news:a3aa4d98-e0df-4bf9-9222-6e17e74fe840@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On Sep 26, 3:32 pm, "MikeD" <nob...@xxxxxxxxxxx> wrote:
However, if you need to preserve "breakpoints", I recommend you
add Debug.Assert statements into your code. You can also use
the Stop statement to enter into break mode, but you must be
very (VERY) careful to remove them because Stop statements will
terminate your compiled program, whereas Debug.Assert statements
don't even get compiled (with one exception, consult
VB's Help for more info).
--
Mike
Microsoft MVP Visual Basic
Thanks for your reply, Mike!
Unfortunately, adding a Debug.Assert is not an option. Since
I am whitebox-testing the code, it must not change during
the course of the test. Plus, my self-written add-in that
guides me to the code lines I need to test is line-number
based, I would cause myself some extra grief if I added
code lines.
The strange thing: I once considered to add a breakpoint
save/restore into my own add-in. Back then, I couldn't
find any interface to access breakpoint data of the IDE.
I once worked in a shop with similar constraints.
There are two ways to provide conditional preserved breakpoints. You will
likely use both schemes.
Scheme 1:
' A module scope constant that is set during testing in the IDE
Const NDebug As Boolean = False ' Note reversed logic
' Debug Assert statements will be cleaned from compiled code
Debug.Assert (NDebug)
White-box testing takes a degree of assistance from the initial programmer
as code should be written with testing in mind. The programmer has
(hopefully <g>) already done a certain amount of testing before the code is
released so logical 'stopping points' have already been identified and
Assert statements can be used. In this case just leave the Debug.Assert
statements in the code. They can remain labeled without any impact on
released code.
Also consider you can easily add a number of obvious test-patterns by
perhaps using several "DebugModes"...
Const DebugNewCustomer As Boolean = True
Const DebugTax = False
....
This will take care of the majority of stopping-points that will be using on
a regular testing schedule.
Now is also a good time to investigate using the Debug.Assert statement for
its intented purpose, and that is to "Assert" that something is true at this
point or holler loudly if it isn't. Making such statements manditory within
critical code sections is a best practice.
Scheme 2:
' A compile time constant which is also set during testing
' and specifically turned off for production builds
#Const DebugMode = True
#If DebugMode Then
' Debug print args/statements will be in compiled code with this
' switch on, but removed if off.
Debug.Print "This is a breakpoint"
' not compiled in released code
Debug.Assert (True)
#End If
Simply re-write your Addin to ignore lines between #If...#End If statements.
(You could just as easily just ignore "Debug. ..." statements.)
Line numbering should always be done with 'room' between statements. That's
why Addins that provide line-numbers increment them by 10. Nine extra lines
between labels should be room enough for inserting temporary code. Or by
using scheme two above can remain permanently in your code.
Once you start using line-numbering beyond a simple quick debugging device
then those labels become as much a part of the code as the code statements
themselves. Line Numbers have no ordinal or cardinal value. They are simply
labels.
If you want a simple way to inert #If...#End If statements or manage
line-numbering take a look at MZTools
(http://www.mztools.com/v3/download.aspx).
hth
-ralph
.
- Follow-Ups:
- Re: Saving breakpoints
- From: asperamanca
- Re: Saving breakpoints
- References:
- Saving breakpoints
- From: asperamanca
- Re: Saving breakpoints
- From: MikeD
- Re: Saving breakpoints
- From: asperamanca
- Saving breakpoints
- Prev by Date: Re: VB Express 2008 Tutorial/Good Book
- Next by Date: Re: Auto Indent - what I am missing?
- Previous by thread: Re: Saving breakpoints
- Next by thread: Re: Saving breakpoints
- Index(es):
Relevant Pages
|