logo       

Re: FAQ entry critique (Re: Re: distinguishing between failures and errors): msg#00144

java.junit.user

Subject: Re: FAQ entry critique (Re: Re: distinguishing between failures and errors)

J. B. Rainsberger wrote:

>>
>> public void testNonexistentFileRead() throws IOException {
>> try {
>>
>> File file = new File("doesNotExist.txt");
>> FileReader reader = new FileReader(file);
>> assertEquals('a', (char)reader.read());
>>
>> fail("Should have thrown FileNotFoundException");
>>
>
>Suggestion: change the failure message to "Read from a nonexistent file?!". I
>prefer this pattern because it indicates what the system did incorrectly in a
>higher-level way. I also think it's funnier when I see it in the test
>results. ;)
>

Yeah, and then append "I'm sorry, Dave, I'm afraid I can't do that" to
all the failures by default.

:-)

Mike



[Non-text portions of this message have been removed]




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise