[Cuis-dev] Test error message wrongly formatted

Gerald Klix cuis.01 at klix.ch
Mon Jul 31 00:57:24 PDT 2023


Hi Guys,

Finally I could not resist and state my suggestion:

Let's stick to the English meaning of that selector:
It asserts that one value is equal to another value
and nothing more. Even in English, which sometimes
has rather "colorful" semantics, equality is symmetric.

So let's replace the terms 'actual value" and 'expected value'
with value 'one value' and  'another value'.

Just my (old fashioned) DM 2,50.


Best Regards,

Gerald




On 7/31/23 12:29 AM, Juan Vuletich via Cuis-dev wrote:
> Hi Folks,
>
> I am delighted and amazed to see this kind of conversation taking 
> place in our community. Martin, this is invaluable! Thank you all.
>
> On 7/30/2023 7:15 PM, Hernán Wilkinson via Cuis-dev wrote:
>> Hi Martin,
>>  thank you for your explanation! I thought it was in SUnit because 
>> JUnit, NUnit and others have the assert:equals: (or 
>> assertEquals(...), etc) and I thought they took it from SUnit. But 
>> you are right, I remember using SUnit back in 2002 and no 
>> assert:equals: existed, I saw it the first time in JUnit.
>>  JUnit, NUnit, etc have the expected as first parameter. Maybe the 
>> one we have now was copied from JUnit that follows that convention 
>> then...
>>  Regarding what to do with the parameters order, now with your 
>> explanation I do not have a preference... if there are non historical 
>> reasons then maybe having actual first is better, is what most people 
>> think it should be (even me!). It won't be the same as JUnit but I 
>> think we do not really care about that, do we? :-)
>
> I would care a bit about JUnit, but indeed I care more about the wider 
> Smalltalk community. It seems we inherited the confusion from Squeak. 
> I take Pharo's side on this one, and I suggest following Martin's 
> advice, even if we'll need to review quite a few tests.
>
> Thanks,
>
>>
>> Cheers!
>> Hernan.
>>
>> On Sun, Jul 30, 2023 at 6:59 PM Martin McClure <martin at hand2mouse.com 
>> <mailto:martin at hand2mouse.com>> wrote:
>>
>>     Hi Hernán,
>>
>>     I'm afraid you can't blame Kent Beck for this ambiguity.
>>
>>     #assert:equals: was not in Kent's original SUnit design -- at
>>     least it's
>>     not in his paper from 1999, and it's not in Camp Smalltalk SUnit 3.1
>>     from 2003.
>>
>>     At GemStone, we have an internal test framework that existed before
>>     SUnit did, and its primary way of doing assertions is
>>
>>          self run: aBlock forResult: anObject.
>>
>>     Fifteen years ago or so, Niall Ross was the primary SUnit 
>> maintainer,
>>     and I suggested to him that SUnit could benefit from something like
>>     #run:forResult:. He didn't think that particular selector fit 
>> SUnit's
>>     way of doing things, but for SUnit 4.0 (2009 or so) he added
>>     #assert:equals:.
>>
>>     Niall's code did not specify which argument is the expected and 
>> which
>>     the actual. The failure description just says "a is not equal to
>>     b." So
>>     it was left ambiguous.
>>
>>     However, I was never in doubt that the "proper" usage was "assert:
>>     actual equals: expected." And there's quite a lot of Smalltalk
>>     code that
>>     uses it that way. A random sampling of GemStone's many tests shows
>>     exactly none that put the expected value first. And Pharo explicitly
>>     shows which is which, their message pattern in TestAsserter is
>>
>>         assert: actual equals: expected
>>
>>     and their tests follow that usage.
>>
>>     So, since "we all expect the actual to be first" and there's a
>>     quite lot
>>     of code in Smalltalk-land that agrees with that, I'd suggest that
>>     Cuis
>>     follow suit.
>>
>>     Regards,
>>     -Martin
>>
>>
>>     On 7/23/23 19:29, Hernán Wilkinson via Cuis-dev wrote:
>>     > Hi Hilaire
>>     >  I think all of us that used #assert:equals: had the same
>>     feeling as
>>     > you someday.
>>     >  We all expect the actual to be first, but for some reason I do 
>> not
>>     > know Kent Beck put the expected first when he wrote SUnit and
>>     all the
>>     > descendant testing framework followed that convention (JUnit,
>>     NUnit,
>>     > phpunit, etc etc).
>>     >  We should not change it for historical and compatibility reasons.
>>     >  Adding the message you suggest will not harm, but it is
>>     redundant...
>>     >  My advice, give it a couple of days, you will get used to it to
>>     put
>>     > the expected first, it is a matter of time.
>>     >
>>
>>
>>
>> -- 
>> *Hernán Wilkinson
>> Agile Software Development, Teaching & Coaching*
>> *Phone: +54-011*-4893-2057
>> *Twitter: @HernanWilkinson*
>> *site: http://www.10Pines.com <http://www.10pines.com/>*
>> Address: Alem 896, Floor 6, Buenos Aires, Argentina
>
>
>



More information about the Cuis-dev mailing list