2010/6/27 Benoit St-Jean <bstj...@hotmail.ca>

>  Hi Laurent,
>
> Perhaps I am missing something but you only need 2 conditions to detect
> what you are looking for:
>
> 1) changed method is a test (and defined in a subclass of TestCase)
> 2) changed method has a sender that is a test method
>

First Autotest versions have these two heuristics. Then I feel the need to
add:
- change method is a setUp or tearDown -> run all tests of TestCase
- and now when there's no senders of changed method in a TestCase (a private
method for example) -> try to find tests of the changed method class  (I
think it can be better but I have no other solution yet)

Indeed, using Autotest I feel the need to be sure that the method I've
changed has been called. I would like to see a warning if it's not the case.

Cheers

Laurent



>
>
>
> -----------------
> Benoit St-Jean
> A standpoint is an intellectual horizon of radius zero.
> (Albert Einstein)
>
>
>
>
> ------------------------------
> From: laurent.laff...@gmail.com
> Date: Sun, 27 Jun 2010 17:33:53 +0200
> To: pharo-project@lists.gforge.inria.fr
> Subject: [Pharo-project] Xtreme Pharo hacker needed :)
>
>
> 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/
>
> ------------------------------
> Enter for a chance to get your town photo on Bing.ca! Submit a Photo Now!
> <http://go.microsoft.com/?linkid=9734379>
>
> _______________________________________________
> Pharo-project mailing list
> Pharo-project@lists.gforge.inria.fr
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
_______________________________________________
Pharo-project mailing list
Pharo-project@lists.gforge.inria.fr
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

Reply via email to