[Pharo-project] I am the only one who finds #assert:equals: oppostite to expected?

Stéphane Ducasse stephane.ducasse at inria.fr
Sat Apr 30 17:59:50 CEST 2011


mariano since the API is the same I guess that we can change to get the behavior you expect.

I'm still convinced that we should develop another testing framework because just to be compatible 
with SUnit we are bound to never change. At brest I discuss and gave a list of features to niall
and I still do not know what happened to them....

Stef

> Hi guys. I always code my tests something like this:
> 
> testBlah
>     | universalAnswer |
>     universalAnswer := 30.
>     universalAnswer := universalAnswer + 11.
>     self assert: universalAnswer equals: 42.
> 
> In this case, 42 is the "expected" and "universalAnswer" is the "actual" value. 
> I feel weird writing like this:
> 
>     self assert: 42 equals: universalAnswer.
> 
> I don't know why...but I do..the same as when doing should: []  raise: Error.
> In that case you put the "actual" first and the "expected" at the end...
> 
> ok....the "problem" is that assert:equals:  is in fact:   asserts: expected equals: actual  instead of 
> asserts: actual equals: expected
> 
> So, with my test I would receive a description in the debugger that says "'Expected 41 but was 42.'"
> which is completely the opposite. Of course, if I write my tests in the way I don't like, that is:
>  self assert: 42 equals: universalAnswer.
> 
> then i got the correct message "'Expected 42 but was 41.'"
> 
> I don't pretend pharo change this because I guess it is standard, and blah blah blah. But senders of #assert:equals: should both, some written as mine (so the message is incorrect for them) and some correct. 
> 
> In addition, I think it is a problem of the selector name. If we could make it clearer, the won't be necessary to confuse "actual" with "expected". 
> 
> Cheers
> 
> -- 
> Mariano
> http://marianopeck.wordpress.com
> 




More information about the Pharo-project mailing list