FitNesse:无法看到断言失败中预期结果与实际结果之间的差异
我正在使用 FitNesse 来测试 Web 服务响应,并使用 check
来比较预期响应与实际响应。
在某些情况下,检查失败,我看不出导致检查失败的预期与实际之间有什么差异。
这是它在一个特定实例(许多类似实例)中告诉我的内容的屏幕截图:
随意指出明显的问题;它可能正盯着我的脸,但我看得太仔细了,却看不到它!
I'm using FitNesse to test web service responses using check
to compare the expected to the actual response.
In some cases the check is failing and I can't see what the differences are between the expected and the actual that is causing it to fail.
Here's a screenshot from what it's telling me in a specific instance (of many similar instances):
Feel free to point out the obvious; it's probably staring at me in the face and I'm looking so hard I can't see it!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您的字符串的实际值可能包含额外的空格。 FitNesse 基于 html,不会考虑前导或尾随空格。它也可能无法处理实际中的任何额外空间。所以这可能会导致结果不同,但不是明显的不同。
看看是否可以添加一些调试消息来帮助您查看额外的空格,或者至少计算两个字符串中的字符数。
It is possible that your string contains extra spaces in the actual value. FitNesse, being html based, will not respect leading or trailing spaces. It might not handle any extra spaces inside the actual either. So this can cause the result to be different, but not visibly so.
See if you can add some debug messages that would help you see the extra spaces, or at least count the number of characters in both strings.
我会检查预期字符串和实际字符串是否都使用相同的文本编码编写。当由于逗号或撇号以不同的编码写入而导致文本比较失败时,我多次看到此错误。
I would check that the expected and actual strings are both written with the same text encoding. I've seen this error plenty of times when the text comparing failed due to a comma or apostrophe being written in different encodes.
这个问题没有指定是否使用 Slim 或 Fit,或者如果使用 Slim 则使用哪个 Slim 服务器/插件,但我发现以下内容对我使用 FitNesse 版本 20130530 和 fitSharp 版本 是正确的>2.2:
由于 [1],我对非 ASCII 字符进行 HTML 编码(但不是 HTML 语法字符或引号)。由于 [2] 和 [3],我现在从夹具返回值中删除回车符。这两项更改似乎都为我解决了这个问题,并且现在报告的预期值和实际值是相同的。
This question doesn't specify whether Slim or Fit are being used, or which Slim server/plugin if using Slim, but I found the following to be true for me using FitNesse release 20130530 and fitSharp release 2.2:
Because of [1], I'm HTML-encoding non-ASCII characters (but not the HTML syntax characters or quotes). Because of [2] and [3], I'm now removing carriage return characters from my fixture return values. Both changes seem to have resolved this issue for me and expected and actual values are now reported as being the same.
空白经常困扰我。生成的 HTML 只是折叠空格,但代码中的比较却不会。
我现在使用夹具来使差异对我来说更加明确。用法示例: http://fhoeben.github.io/hsac-fitnesse-fixtures/examples-results/HsacExamples.SlimTests.UtilityFixtures.CompareFixtureTest.html
新版本的 FitNesse(自 20151230 起)进行了比较预期和实际结果值。这对你有帮助吗?
Whitespace has troubled me often. The resulting HTML just collapses whitespace, but the compare in code does not.
I now use a fixture to make differences more explicit to me. Example usage: http://fhoeben.github.io/hsac-fitnesse-fixtures/examples-results/HsacExamples.SlimTests.UtilityFixtures.CompareFixtureTest.html
Newer versions of FitNesse (since 20151230) do a diff on the expected and actual result values. Has that helped you at all?