harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Richard Liang <richard.lian...@gmail.com>
Subject Re: assertEquals in tests with incorrect argument order
Date Mon, 17 Apr 2006 00:53:39 GMT
Mark Hindess wrote:
> Another type of test that could be improved are those using
> assertTrue to compare two objects for equality.  Most of them should
> be using assertEquals, assertNull or assertNotNull.
>
> Using assertEquals automatically gives more meaningful error messages.
>   
I strongly support this idea. We should always try our best to make our 
test cases give meaningful message. :-)
> It saves people writing asserts like:
>
>   assertTrue("Size should return 100, returned: " + map.size(),
>              map.size() == 100);
>
> when this would do just as well:
>
>   assertEquals("Incorrect size", 100, map.size());
>
> I'm going to submit a few (big) patches to fix some of these.
>
> Regards,
>  Mark.
>
> On 4/15/06, Mark Hindess <mark.hindess@googlemail.com> wrote:
>   
>> Trying to fix/enable the PatternSyntaxExceptionTest (HARMONY-352) was
>> quite confusing.  If you get the arguments to assertEquals the wrong
>> way around you get errors like:
>>
>>   error expected <actual> but got <expected>
>>
>> rather than:
>>
>>   error expected <expected> but got <actual>
>>
>> The correct way around is to have the expected value before the actual value.
>> We should all try make sure we get the arguments to assertEquals in the
>> correct order.  And fix any we spot that are the wrong way around. ;-)
>>
>> I've fixed a few of the more obviously incorrect method calls in
>> HARMONY-353.
>>
>> Regards,
>>  Mark.
>>
>> --
>> Mark Hindess <mark.hindess@googlemail.com>
>> IBM Java Technology Centre, UK.
>>
>>     
>
>
> --
> Mark Hindess <mark.hindess@googlemail.com>
> IBM Java Technology Centre, UK.
>
> ---------------------------------------------------------------------
> Terms of use : http://incubator.apache.org/harmony/mailing.html
> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>
>
>   


-- 
Richard Liang
China Software Development Lab, IBM 


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message