如何格式化“Diff”黄瓜输出
我有一个场景大纲,它将方法的结果与应返回的数组进行比较。因此,当它们不匹配时,我会得到一系列这样的语句:
expected: ["a", "b", "c", "d", "e", "f"]
got: ["c", "d", "e", "f", "g"] (using ==)
Diff:
@@ -1,2 +1,8 @@
-["a", "b", "c", "d", "e", "f"]
+["c",
+ "d",
+ "e",
+ "f",
+ "g"]
这不是最简洁或最有用的输出。像这样显示会更有帮助:
expected: ["a", "b", "c", "d", "e", "f"]
got: ["c", "d", "e", "f", "g"] (using ==)
Diff:
@@ -1,2 +1,8 @@
-["a", "b"]
+["g"]
这样我可以立即看到哪些值是附加的或缺失的。
I have a scenario outline that compares the results of a method to the array that should be returned. So I get a series of statements like this when they don't match:
expected: ["a", "b", "c", "d", "e", "f"]
got: ["c", "d", "e", "f", "g"] (using ==)
Diff:
@@ -1,2 +1,8 @@
-["a", "b", "c", "d", "e", "f"]
+["c",
+ "d",
+ "e",
+ "f",
+ "g"]
This is not the most succinct or helpful output. It would be much more helpful to be dipslay like:
expected: ["a", "b", "c", "d", "e", "f"]
got: ["c", "d", "e", "f", "g"] (using ==)
Diff:
@@ -1,2 +1,8 @@
-["a", "b"]
+["g"]
This way I could instantly see what values were additional or missing.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用数组差分法:
Use the Array difference method: