FitNesse:无法看到断言失败中预期结果与实际结果之间的差异

发布于 2024-12-26 05:46:31 字数 268 浏览 1 评论 0原文

我正在使用 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):
Here's an example where it's failing and I can't see why

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

老娘不死你永远是小三 2025-01-02 05:46:31

您的字符串的实际值可能包含额外的空格。 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.

半寸时光 2025-01-02 05:46:31

我会检查预期字符串和实际字符串是否都使用相同的文本编码编写。当由于逗号或撇号以不同的编码写入而导致文本比较失败时,我多次看到此错误。

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.

(り薆情海 2025-01-02 05:46:31

这个问题没有指定是否使用 Slim 或 Fit,或者如果使用 Slim 则使用哪个 Slim 服务器/插件,但我发现以下内容对我使用 FitNesse 版本 20130530 和 fitSharp 版本 是正确的>2.2

  1. 作为字符串的输入参数/参数中的非 ASCII 字符和 { 撇号/单引号字符 } 是 HTML 编码的。我的 FitNesse 测试表中的值是 HTML 编码的,但只有所需的语法字符和(双)引号;不是非 ASCII 字符(FitNesse 存储这些值似乎没有任何问题)。
  2. 作为字符串的输入参数中的 EOL 字符仅由换行符组成。
  3. 我认为因为我使用的是 .NET,所以返回值中的 EOL 由回车符和换行符组成。

由于 [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:

  1. Non-ASCII characters and { apostrophes / single quote characters } in input arguments/parameters that are strings are HTML encoded. The values in my FitNesse test tables are HTML encoded, but only the required syntax characters and (double) quotes; not the non-ASCII characters (and FitNesse doesn't seem to have any problems storing those values).
  2. EOL characters in the input arguments that are strings consist of a linefeed character only
  3. I imagine that because I'm using .NET, EOLs in my return values consist of carriage return and linefeed characters.

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.

白鸥掠海 2025-01-02 05:46:31

空白经常困扰我。生成的 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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文