简体   繁体   English

如何格式化黄瓜中的“差异”输出

[英]How do I format the “Diff” output in cucumber

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. 这样,我可以立即看到哪些值是额外的或丢失的。

使用数组差异方法:

(expected_array - actual_array).should == []

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM