Let's say you check whether two values are equal. Your check can go wrong in two ways: The values are equal, but the string representation is not (this is unlikely). The values are different, but the string representation is the same (say the values are 0.048 and 0.052 and both are represented as the string "0.05").
- The values are equal, but the string representation is not (this is unlikely).
- The values are different, but the string representation is the same (say the values are 0.048 and 0.052 and both are represented as the string "0.05").
The second misses a test failure, and worse, it misses a subtle test failure that you won't pick up otherwise. The first case is reasonably harmless - it's annoying because you have a test that fails but shouldn't so you fix the test.
Where it gets really bad is if your test should compare three values a, b, c and you totally missed that your text representation only contains a and b. Now c is completely untested.
So you need some very, very good unit tests for toString()toString() first if you want to rely on it in a unit test.