开发者

How do I format the "Diff" output in cucumber

开发者 https://www.devze.com 2023-03-05 04:06 出处:网络
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:

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 == []
0

精彩评论

暂无评论...
验证码 换一张
取 消