Hi,
I struggle for a functionality I want to add on Autotest. Suppose a class with two methods A and B, such as A senders of B
Zork>>methodA
���� self methodB
And unit tests:
ZorkTest>>testSomething
���� .....
���� Zork new methodA
����...
����self assert: ....
If I change methodA, Autotest detects it, search all senders of methodA in tests and run. As ��ZorkTest>>testSomething is sender of��Zork>>methodA, it will find and run it.
Now if I change methodB and there's no senders in tests, the previous heuristic won't work. So I added as last heuristic: if no method found, search all TestCases that references the changed method class and run.��
So here it will find ZorkTest and run all its tests.��
The problem is that I don't really know if the method I've changed has been actually "hit" by the tests. I just see that tests has been run. I don't know if my method has been called when running the tests.��
So I want to detect this.
One way of doing this seems to use MethodContext>>runSimulated:contextAtEachStep:. I've found this looking at MessageTally. Is it the best solution ?
So in Autotest>>findRunAndShowTestsOf: I try something like this
Autotest>>findRunAndShowTestsOf:changedMethod
����| testMethods aTestResult methodHit |
����"Finds the test related to changedMethod, run them and tell the view to update"
testMethods := search methodsFor: changedMethod.
methodHit := false.
thisContext sender
runSimulated: [aTestResult := runner run: testMethods]��
contextAtEachStep: [:current| ��
(current method = changedMethod) �� ��"<--- here I detect if changedMethod has been hit"
���� �� �� ifTrue: [methodHit := true]].
���� �� �� ��.....
but using this debugger opens with "SimulationGuardException: triggered by BlockClosure>>newProcess" in MethodContext>>doPrimitive:method:receiver:args:��
As I don't (yet :) understand all this stuff, I want to know if it's the right way to do it and what should I check.
Thanks
Laurent Laffont
http://pharocasts.blogspot.com/
http://magaloma.blogspot.com/