简体   繁体   中英

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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