You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@harmony.apache.org by Tim Ellison <t....@gmail.com> on 2006/05/12 17:49:47 UTC

Re: [classlib] exception messages

Mikhail Loenko wrote:
> 2006/5/12, Tim Ellison <t....@gmail.com>:
>> 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 (t.p.ellison@gmail.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