In this session, I’d like to complete the one
about the debugger and show you how to detect a bug.
Let’s imagine we change the decrement definition
and we make a mistake.
Here, I put an addition instead of a substraction.
When I run my tests, the TestDecrement returns false.
I execute it, I look at the execution and I notice
that indeed count returns 9 instead of 5.
So it shows that I do have an error among these
expressions, if I consider that the counter has been created.
Here I’d like to execute
the code and stop just after
the Counter creation to see which methods
have a problem.
i add Self halt, this is one of the ways to propose a
break point in Pharo. I compile again the method, I do
Proceed, the code is executed and stops on the halt method.
So now I click on “Over”.
I can decide to go inside
the count method, that’s what I do for example,
I can see that count value is nil and Integer value is 7
like here, and there I can click on “Over”.
I go back, I have decrement.
I’m going to look inside it
because the problem must be there, and here
I can see that decrement is equal to -1.
I modify it, “Over”.
And now I can click on “Proceed”.
When I click on “Proceed” the debug is left, I remove it,
I click on “Proceed” and my test is green.