commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oliver Heger <oliver.he...@t-online.de>
Subject Re: svn commit: r233505 - in /jakarta/commons/proper/configuration/trunk/src:
Date Mon, 22 Aug 2005 18:04:11 GMT
In this case I agree with Brett. An uncought exception will be no 
problem in a unit test. The fact that junit distinguishes between 
failures and errors should especially direct the developer's attention 
to that problem.

Oliver

Brett Porter wrote:

>I'm a little lost on this criticism also... a test that doesn't catch an
>uncaught exception will error out. An error with a trace would be more
>obvious to me than the assertEquals below, and much easier to read.
>
>Henning P. Schmiedehausen wrote:
>
>  
>
>>oheger@apache.org writes:
>>
>> 
>>
>>    
>>
>>>+        try
>>>+        {
>>>+            it.next();
>>>+            fail("Could iterate over the iteration's end!");
>>>+        }
>>>+        catch(NoSuchElementException nex)
>>>+        {
>>>+            //ok
>>>+        }
>>>   
>>>
>>>      
>>>
>>This allows it.next() to throw another exception which leads to an
>>unchecked test failure. I found that using
>>
>>   try
>>   {
>>	it.next();
>>	fail("Could iterate over the iteration's end!");
>>   }
>>   catch(Exception e)
>>   {
>>	assertEquals("it.next() over end threw wrong exception", NoSuchElementException.class,
e.getClass())
>>   }
>>
>>is more stable in the long run, because it makes sure that every
>>exception thrown by it.next() is caught.
>>
>>	Regards
>>		Henning
>>
>> 
>>
>>    
>>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
>
>  
>


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message