Mikhail Loenko wrote:
> 2006/5/12, Tim Ellison <[EMAIL PROTECTED]>:
>> Tests shouldn't assert the actual message String in an exception.
> 
> I disagree. We need some technique to test exception messages.
> As I wrote in the thread "should strings in exceptions match the
> reference implementation?" sometimes (e.g. in regex) we do have to
> test the messages

I just went back to re-read your note (sorry I can't reference it 'cos
he archive is down).

You cite
        tests/api/java/util/regex/PatternSyntaxExceptionTest

as rationale (which I note has been changed so it doesn't check the
actual messages any more ;-) )

The spec for getMessage() [1] says:

"Returns a multi-line string containing the description of the syntax
error and its index, the erroneous regular-expression pattern, and a
visual indication of the error index within the pattern."

The only parts of that I can imagine testing with an API test are :
- the string has multiple-lines
- it contains "the erroneous regular-expression pattern"

So let me refine my position to say, "our API tests shouldn't be
asserting the value of unspecified parts of an exception message".  Does
that make sense?

Of course, the reason for this is to ensure that we don't end up with
lots of exception tests that fail when we translate the message strings.

Regards,
Tim

[1]
http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/PatternSyntaxException.html#getMessage()
-- 

Tim Ellison ([EMAIL PROTECTED])
IBM Java technology centre, UK.

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to