Multiline-friendly toString()
- Dominant language
- Java
- Stars
- 10.6k
- Forks
- 1.2k
- Avg merge
- 6h 32m
- Merged PRs (30d)
- 13
Description
One of the things we did in Truth a while back was to print values differently if they contain newlines. So, for example, you would see:
```
expected: foo
but was : bar
````
But you'd see:
```
expected:
public class Foo {
Foo() {}
}
but was:
public class Bar {
Bar() {}
}
````
I would speculate (but it's just speculation) that this might be a nice feature for AutoValue `toString()` implementations, too.
(Even in the case in which fields _aren't_ multiline, a multiline `toString()` can be nice in some cases: I think Truth has gotten reports that AutoValue `toString()` (like, to be fair, almost all `toString()` implementations) makes it hard to see which field differs when there are a lot of fields. But of course one-line `toString()` is nice in plenty of cases, too, so I wouldn't advocate for _always_ going multiline (nor, probably, for making it configurable). It's just a nice additional advantage in the cases in which multiline is already justified.)
(It's also possible that Truth should have more special handling of AutoValue types in some cases.)
Contributor guide
Assessment
This issue has not been assessed yet.