Use Truth to compare proto to string
Use Truth to compare proto to string Is there a way to use Google Truth to compare a protobuff to a string? I am hoping to find something that looks like this: assertThat(myProto).isEqualToString("a: 1n b:2") 1 Answer 1 Truth provides an extension for protocol buffer assertions, which is probably what you should use. Asserting on a message's string format is going to be brittle, and failures will be harder to understand. That said you certainly can do what you're asking: assertThat(myProto.toString()).isEqualTo("a: 1n b:2"); By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.