[Pharo-users] Failling Tests are green if BlockCannotReturn exception
alidrandco at yahoo.fr
Wed Jan 13 12:42:20 EST 2016
Thank you all for your responses.
I see your point about returning from a block. Because the return in this example is very explicit. But what if I put (by mistake) a return in a block in a method that is called by the test method (or even in a method that is called by another method that is called by the test method) then I would have no reason to doubt my test was successful whereas it would have failed if it was run till the last assertion.
My point is, would it not be interesting to report tests that were not run successfully till the end?
De : Sven Van Caekenberghe <sven at stfx.eu>
À : abdelghani ALIDRA <alidrandco at yahoo.fr>; Any question about pharo is welcome <pharo-users at lists.pharo.org>
Envoyé le : Mardi 12 janvier 2016 7h35
Objet : Re: [Pharo-users] Failling Tests are green if BlockCannotReturn exception
> On 12 Jan 2016, at 00:26, abdelghani ALIDRA <alidrandco at yahoo.fr> wrote:
> I observed this unexpected behavior in test classes.
> In a test class define a method :
> aBlock := [ ^1 ].
> aBlock value.
> self assert: false.
> Althought the assertion is false at the end of the test, the test is green.
> Actually, It does not matter what you put after aBlock value, the test always succedes (I tried to put a self halt, it does not execute)
The test is 'does an explicit return from a block return from the whole method'. Of course it does. But if it would not, you would arrive at the self assert: false and the test would fail. You see ?
BTW, this can also be written as self fail - search for the senders of that message for more examples.
> I tried this both in Pharo 4 and 5 under Windows and MacOS.
> Any ideas?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Pharo-users