[Pharo-dev] Use #shouldnt:raise: only with specific errors, or evaluate the given expression directly

Alexandre Bergel alexandre.bergel at me.com
Mon Oct 21 18:20:20 EDT 2013


Instead of using shouldnt:raise:, you can simply remove the assertion, as in:

-=-=-=-=-=-=-=-=-=
testNoErrorWhenDrawing
	self shouldnt: [ view raw drawOn: tracingCanvas ] raise: Error
-=-=-=-=-=-=-=-=-=

||
V

-=-=-=-=-=-=-=-=-=
testNoErrorWhenDrawing
	view raw drawOn: tracingCanvas
-=-=-=-=-=-=-=-=-=

With the second version of the test, the test may be listed as an error in case of an exception, whereas the first version it can only be listed as a failure.
I read your post and I kind of agree.
I will fix my tests then.

Alexandre


On Oct 22, 2013, at 12:08 AM, Camillo Bruni <camillobruni at gmail.com> wrote:

> see my long explanation here https://pharo.fogbugz.com/default.asp?11876#87218
> it looks unsuspicous until the moment you try understand such a failing assertion.
> 
> On 2013-10-21, at 23:42, Alexandre Bergel <alexandre.bergel at me.com> wrote:
> 
>> Hi!
>> 
>> Just to share some thought.
>> I am now playing with Pharo 3. I have seen TestCase has some additional checks for assertion with exception. I perfectly understand the idea behind this, however, on the other hand, I see nothing suspect with the following assertion (which Roassal's tests are full of):
>> 
>> 	self shouldnt: [ view raw drawOn: tracingCanvas ] raise: Error
>> 
>> I have to shut down the method #validateShouldntException:
>> 
>> Cheers,
>> Alexandre
>> -- 
>> _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
>> Alexandre Bergel  http://www.bergel.eu
>> ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
>> 
>> 
>> 
>> 
> 

-- 
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel  http://www.bergel.eu
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.







More information about the Pharo-dev mailing list