簡體   English   中英

如何格式化黃瓜中的“差異”輸出

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

我有一個方案大綱,將方法的結果與應返回的數組進行比較。 因此,當它們不匹配時,我會得到一系列這樣的語句:

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"]

這樣,我可以立即看到哪些值是額外的或丟失的。

使用數組差異方法:

(expected_array - actual_array).should == []

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM