[squeak-dev] BlockContextTest >> #testNew

Chris Muller asqueaker at gmail.com
Thu Jan 9 16:25:32 UTC 2014


Yea, the code definitely appears wrong for testing, but is it really
useful to assert the *exact wording* of an error message, and
duplicate it 4 times?

I regard the messageText of Exceptions to be "for human consumption
only".  Any time I see code that thinks its necessary to check the
wording of an exception makes me want to say, "If you think you need
to do that then you your own Exception subclass."

So, of the 4 tests in this method, I think the second one should be
removed, and the last two should be made like the first one (e.g.,
without the string literals).

On Thu, Jan 9, 2014 at 7:30 AM, Frank Shearar <frank.shearar at gmail.com> wrote:
> testNew
>     self should: [ContextPart new: 5] raise: Error.
>     [ContextPart new: 5]
>         ifError: [:error :receiver | error = 'Error: Contexts must
> only be created with newForMethod:'].
>     [ContextPart new]
>         ifError: [:error :receiver | error = 'Error: Contexts must
> only be created with newForMethod:'].
>     [ContextPart basicNew]
>         ifError: [:error :receiver | error = 'Error: Contexts must
> only be created with newForMethod:'].
>
> Surely those "error = " lines need asserts?
>
> frank
>


More information about the Squeak-dev mailing list