Hi, I see many usage of #should: in SciSmalltalk tests that could simply be turned into #assert: or eventually #assert:equals: Why wanting to use a block? Other than #should:raise: and #shouldnt:raise:, I don't really see the point of #should: alone anyway... IMO should: should be deprecated, less is more. I'm possibly the author of several of these #should: sends, so don't take it personnally ;) P.S. or is it easier to restart the block in the Debugger? I cross post to pharo-dev because it's a generic question, and there are a few #should: sends in Pharo-3.0 too.
Some not so different opinion: http://joachimtuchel.wordpress.com/2011/09/15/sunit-and-shouldshouldnt-vs-as... 2014-05-01 0:52 GMT+02:00 Nicolas Cellier < nicolas.cellier.aka.nice@gmail.com>:
Hi, I see many usage of #should: in SciSmalltalk tests that could simply be turned into #assert: or eventually #assert:equals: Why wanting to use a block? Other than #should:raise: and #shouldnt:raise:, I don't really see the point of #should: alone anyway... IMO should: should be deprecated, less is more. I'm possibly the author of several of these #should: sends, so don't take it personnally ;)
P.S. or is it easier to restart the block in the Debugger? I cross post to pharo-dev because it's a generic question, and there are a few #should: sends in Pharo-3.0 too.
-- You received this message because you are subscribed to the Google Groups "SciSmalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to scismalltalk+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Hi nicolas just because people do not know. I'm going over the tutorial of Steven Wessels and converting all the should: by assert: too. So I would just change everything and commit. Stef On 1/5/14 00:52, Nicolas Cellier wrote:
Hi, I see many usage of #should: in SciSmalltalk tests that could simply be turned into #assert: or eventually #assert:equals: Why wanting to use a block? Other than #should:raise: and #shouldnt:raise:, I don't really see the point of #should: alone anyway... IMO should: should be deprecated, less is more. I'm possibly the author of several of these #should: sends, so don't take it personnally ;)
P.S. or is it easier to restart the block in the Debugger? I cross post to pharo-dev because it's a generic question, and there are a few #should: sends in Pharo-3.0 too.
On 01 May 2014, at 00:52, Nicolas Cellier <nicolas.cellier.aka.nice@gmail.com> wrote:
Hi, I see many usage of #should: in SciSmalltalk tests that could simply be turned into #assert: or eventually #assert:equals: Why wanting to use a block? Other than #should:raise: and #shouldnt:raise:, I don't really see the point of #should: alone anyway... IMO should: should be deprecated, less is more. I'm possibly the author of several of these #should: sends, so don't take it personnally ;)
P.S. or is it easier to restart the block in the Debugger? I cross post to pharo-dev because it's a generic question, and there are a few #should: sends in Pharo-3.0 too.
I also do not understand why you would want to use a block. So unless there is a good reason to use that, a simpler API is preferable. BTW, and this was discussed before, #shouldnt:raise: is useless as well ;-)
2014-05-02 0:18 GMT+02:00 Sven Van Caekenberghe <sven@stfx.eu>:
On 01 May 2014, at 00:52, Nicolas Cellier < nicolas.cellier.aka.nice@gmail.com> wrote:
Hi, I see many usage of #should: in SciSmalltalk tests that could simply be turned into #assert: or eventually #assert:equals: Why wanting to use a block? Other than #should:raise: and #shouldnt:raise:, I don't really see the point of #should: alone anyway... IMO should: should be deprecated, less is more. I'm possibly the author of several of these #should: sends, so don't take it personnally ;)
P.S. or is it easier to restart the block in the Debugger? I cross post to pharo-dev because it's a generic question, and there are a few #should: sends in Pharo-3.0 too.
I also do not understand why you would want to use a block. So unless there is a good reason to use that, a simpler API is preferable.
BTW, and this was discussed before, #shouldnt:raise: is useless as well ;-)
Yes, shouldnt: [...] raise: Error is completely useless because SUnit will catch the Error anyway. There are a few examples in SciSmalltalk that should be removed. Most of the time, an Error did effectively occur, so the #shouldnt:raise: tests were conceived as sort of explicit non regression test... But, the tests do not have to carry these historical bits. It's obvious that there should not be an Error raised, and the tests should rather concentrate on testing correctness of the result. I don't remember if there are a few pattern for usage of shouldnt:raise:, I was thinking for example if you want to tests an Exception handler... OK SUnit will catch any kind of Error too, but what if it is a Notification? Nicolas
2014-05-02 9:46 GMT+02:00 Nicolas Cellier < nicolas.cellier.aka.nice@gmail.com>:
2014-05-02 0:18 GMT+02:00 Sven Van Caekenberghe <sven@stfx.eu>:
On 01 May 2014, at 00:52, Nicolas Cellier < nicolas.cellier.aka.nice@gmail.com> wrote:
Hi, I see many usage of #should: in SciSmalltalk tests that could simply be turned into #assert: or eventually #assert:equals: Why wanting to use a block? Other than #should:raise: and #shouldnt:raise:, I don't really see the point of #should: alone anyway... IMO should: should be deprecated, less is more. I'm possibly the author of several of these #should: sends, so don't take it personnally ;)
P.S. or is it easier to restart the block in the Debugger? I cross post to pharo-dev because it's a generic question, and there are a few #should: sends in Pharo-3.0 too.
I also do not understand why you would want to use a block. So unless there is a good reason to use that, a simpler API is preferable.
BTW, and this was discussed before, #shouldnt:raise: is useless as well ;-)
Yes, shouldnt: [...] raise: Error is completely useless because SUnit will catch the Error anyway. There are a few examples in SciSmalltalk that should be removed. Most of the time, an Error did effectively occur, so the #shouldnt:raise: tests were conceived as sort of explicit non regression test... But, the tests do not have to carry these historical bits. It's obvious that there should not be an Error raised, and the tests should rather concentrate on testing correctness of the result.
I don't remember if there are a few pattern for usage of shouldnt:raise:, I was thinking for example if you want to tests an Exception handler... OK SUnit will catch any kind of Error too, but what if it is a Notification?
Nicolas
Ah, here is a pattern that looks completely correct to me:
testIfNil | object block | object := ProtoObject new. self shouldnt: [ object ifNil: [ self halt ]] raise: Halt. self assert: (object ifNil: [ nil ]) == object. "Now the same without inlining." block := [ self halt ]. self shouldnt: [ object ifNil: block ] raise: Halt. block := [ nil ]. self assert: (object ifNil: block) == object.
On 01 May 2014, at 12:52 , Nicolas Cellier <nicolas.cellier.aka.nice@gmail.com> wrote:
Hi, I see many usage of #should: in SciSmalltalk tests that could simply be turned into #assert: or eventually #assert:equals: Why wanting to use a block? Other than #should:raise: and #shouldnt:raise:, I don't really see the point of #should: alone anyway... IMO should: should be deprecated, less is more. I'm possibly the author of several of these #should: sends, so don't take it personnally ;)
P.S. or is it easier to restart the block in the Debugger? I cross post to pharo-dev because it's a generic question, and there are a few #should: sends in Pharo-3.0 too.
Reading code with should:, I always imagined a trailing question mark... self should: [IHaveIceCreamForLunch] ? And even more so with should:raise: self should [thisPieceOfCode] raise: SomeError ? I dunno, you tell me! The potentially constructive suggestion out of that, is that, at least to me, assert:raises: deny:raises: sound more natural than assert:raise: when read out loud. Cheers, Henry
2014-05-02 10:16 GMT+02:00 Henrik Johansen <henrik.s.johansen@veloxit.no>:
On 01 May 2014, at 12:52 , Nicolas Cellier < nicolas.cellier.aka.nice@gmail.com> wrote:
Hi, I see many usage of #should: in SciSmalltalk tests that could simply be turned into #assert: or eventually #assert:equals: Why wanting to use a block? Other than #should:raise: and #shouldnt:raise:, I don't really see the point of #should: alone anyway... IMO should: should be deprecated, less is more. I'm possibly the author of several of these #should: sends, so don't take it personnally ;)
P.S. or is it easier to restart the block in the Debugger? I cross post to pharo-dev because it's a generic question, and there are a few #should: sends in Pharo-3.0 too.
Reading code with should:, I always imagined a trailing question mark...
self should: [IHaveIceCreamForLunch] ?
And even more so with should:raise:
self should [thisPieceOfCode] raise: SomeError ?
I dunno, you tell me!
The potentially constructive suggestion out of that, is that, at least to me, assert:raises: deny:raises: sound more natural than assert:raise: when read out loud.
I see, an affirmative form could be: [thisPieceOfCode] shouldRaise: SomeError but we need to insert the testimony of SUnit... assert:raises: is exactly that, and makes sense
Cheers, Henry
Hi Personally I think the main reason to use #should: is that debugging is easier as you can more easily restart the block in Debugger and replay the failing messages. i.e. think of the #should: as lazily running the code whereas #assert: as being eager because it evaluates the argument immediately. Often Iâll use the #assert:equals: or #assert:description so that I can more easily debug (by restarting the execution in the appropriate test method). I have previously modified the #assert: method to be polymorphic with a boolean or a block so I donât have to use #should: e.g. assert: aBoolean aBoolean value ifFalse: [self logFailure: 'Assertion failed'. self defaultTestFailure signal: âAssertion failed']. Apart from this I agree with all the comments on the doubts of using #should:. Converting #should: calls to #assert: calls is probably not worth the effort unless the #assert: is made polymorphic against a boolean or a block. Cheers Carlo On 01 May 2014, at 12:52 AM, Nicolas Cellier <nicolas.cellier.aka.nice@gmail.com> wrote: Hi, I see many usage of #should: in SciSmalltalk tests that could simply be turned into #assert: or eventually #assert:equals: Why wanting to use a block? Other than #should:raise: and #shouldnt:raise:, I don't really see the point of #should: alone anyway... IMO should: should be deprecated, less is more. I'm possibly the author of several of these #should: sends, so don't take it personnally ;) P.S. or is it easier to restart the block in the Debugger? I cross post to pharo-dev because it's a generic question, and there are a few #should: sends in Pharo-3.0 too.
On Mon, May 5, 2014 at 1:40 PM, Carlo <snoobabk@gmail.com> wrote:
Hi
Personally I think the main reason to use #should: is that debugging is easier as you can more easily restart the block in Debugger and replay the failing messages. i.e. think of the #should: as lazily running the code whereas #assert: as being eager because it evaluates the argument immediately. Often Iâll use the #assert:equals: or #assert:description so that I can more easily debug (by restarting the execution in the appropriate test method). I have previously modified the #assert: method to be polymorphic with a boolean or a block so I donât have to use #should: e.g.
assert: aBoolean aBoolean value ifFalse: [self logFailure: 'Assertion failed'. self defaultTestFailure signal: âAssertion failed'].
Apart from this I agree with all the comments on the doubts of using #should:. Converting #should: calls to #assert: calls is probably not worth the effort unless the #assert: is made polymorphic against a boolean or a block.
+1. But it's trivial to add value to assert: et al...
Cheers Carlo
On 01 May 2014, at 12:52 AM, Nicolas Cellier < nicolas.cellier.aka.nice@gmail.com> wrote:
Hi, I see many usage of #should: in SciSmalltalk tests that could simply be turned into #assert: or eventually #assert:equals: Why wanting to use a block? Other than #should:raise: and #shouldnt:raise:, I don't really see the point of #should: alone anyway... IMO should: should be deprecated, less is more. I'm possibly the author of several of these #should: sends, so don't take it personnally ;)
P.S. or is it easier to restart the block in the Debugger? I cross post to pharo-dev because it's a generic question, and there are a few #should: sends in Pharo-3.0 too.
-- best, Eliot
participants (6)
-
Carlo -
Eliot Miranda -
Henrik Johansen -
Nicolas Cellier -
stepharo -
Sven Van Caekenberghe