How do I format the "Diff" output in cucumber
I have a scenario outline that compares the results of a meth开发者_运维技巧od 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.
Use the Array difference method:
(expected_array - actual_array).should == []
精彩评论