On 7/1/06, Alex Blewitt <[EMAIL PROTECTED]> wrote:

I'd say that (like hashCode()) there's not a lot of point in testing
the exact output, only behaviour. In other words, if it returns a
String, that should be good enough. There's nothing in the spec to say
what it should be -- all of the toString() methods could return
"Harmony is Great!" and it'd still be within spec.


Agree. But there are always exceptions. Some "toString" methods have to
contain some key information as spec required, for example, the size or
index. However, it's still difficult to test the string information.
Generally speaking, I totally agree with you that "if it returns a String,
that should be good enough.".

BTW, are these toString information (RI) copyrighted?

Thanks!


I suspect that tests that look at the exact output for toString() are
being done because it may be a quick-and-dirty way of testing all
properties set in a JavaBean-esque way.

OTOH there are some things that probably are worth testing -- IIRC the
XxxList implementations return [...] when the list grows beyond a
certain size (1000?) to avoid doing an insane amount of toString
calculation. That's the kind of property that I would expect to be
tested in that particular test case.

Alex.

On 30/06/06, Alexei Zakharov <[EMAIL PROTECTED]> wrote:
> Hi community!
>
> While looking through some of java.beans tests I found many places
> where exact output of toString() method is being tested. Moreover, the
> test patterns differ from the output generated by RI's toString's.
>
> IMHO there is no much sense in testing of toString() since normally
> users do not rely on it's output. However, I'd like to listen to
> opinions. Does compatibility testing of toString() make sense to
> anybody?
>
> --
> Alexei Zakharov,
> Intel Middleware Product Division
>
> ---------------------------------------------------------------------
> Terms of use : http://incubator.apache.org/harmony/mailing.html
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

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




--
Andrew Zhang
China Software Development Lab, IBM

Reply via email to