i can has TestCase>>#assert:equals: ?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

i can has TestCase>>#assert:equals: ?

Oscar Nierstrasz

Hi folks,

90% of my tests just test equality of a result to an expected value,  
so I waste time trying to find out what the mismatch is.  Would be  
nice to have this method in SUnit:

assert: result equals: expected
   result = expected
     ifFalse: [self signalFailure: 'Assertion failed: (' , result  
asString , ') ~= (' , expected asString , ')']

Does anyone see a downside, or possible improvements?

- on


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: i can has TestCase>>#assert:equals: ?

Michael Roberts-2
I have used something similar elsewhere. +1 in general.  The only
gotcha is making sure people don't use it for comparing doubles.  If
there are not methods already I would add some form of
assert:equals:tolerance:  or something like that.

cheers,
Mike

On Fri, Apr 10, 2009 at 8:06 PM, Oscar Nierstrasz <[hidden email]> wrote:

>
> Hi folks,
>
> 90% of my tests just test equality of a result to an expected value,
> so I waste time trying to find out what the mismatch is.  Would be
> nice to have this method in SUnit:
>
> assert: result equals: expected
>   result = expected
>     ifFalse: [self signalFailure: 'Assertion failed: (' , result
> asString , ') ~= (' , expected asString , ')']
>
> Does anyone see a downside, or possible improvements?
>
> - on
>
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: i can has TestCase>>#assert:equals: ?

Damien Cassou
In reply to this post by Oscar Nierstrasz
On Fri, Apr 10, 2009 at 9:06 PM, Oscar Nierstrasz <[hidden email]> wrote:

> 90% of my tests just test equality of a result to an expected value,
> so I waste time trying to find out what the mismatch is.  Would be
> nice to have this method in SUnit:
>
> assert: result equals: expected
>   result = expected
>     ifFalse: [self signalFailure: 'Assertion failed: (' , result
> asString , ') ~= (' , expected asString , ')']
>
> Does anyone see a downside, or possible improvements?

No, there is no downside and no possible improvement. All other xUnit
frameworks have that for a long time. I think Keith's version of SUnit
has that too.

--
Damien Cassou
http://damiencassou.seasidehosting.st

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: i can has TestCase>>#assert:equals: ?

Alexandre Bergel
In reply to this post by Oscar Nierstrasz
SUnit should have this methods for years

Alexandre


On 10 Apr 2009, at 21:06, Oscar Nierstrasz wrote:

>
> Hi folks,
>
> 90% of my tests just test equality of a result to an expected value,
> so I waste time trying to find out what the mismatch is.  Would be
> nice to have this method in SUnit:
>
> assert: result equals: expected
>   result = expected
>     ifFalse: [self signalFailure: 'Assertion failed: (' , result
> asString , ') ~= (' , expected asString , ')']
>
> Does anyone see a downside, or possible improvements?
>
> - on
>
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>

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






_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project