使用Truth将proto与string进行比较

时间:2018-03-30 19:10:29

标签: google-truth

有没有办法使用Google Truth比较一个protobuff到一个字符串?我希望能找到这样的东西:

assertThat(myProto).isEqualToString("a: 1\n b:2")

1 个答案:

答案 0 :(得分:0)

Truth为extension提供了一个protocol buffer assertions,您可能应该使用它。声明消息的字符串格式将变得很脆弱,失败将更加难以理解。

这表示您当然可以 执行您要问的事情:

assertThat(myProto.toString()).isEqualTo("a: 1\n b:2");