简体   繁体   English

NUnit Assert - 显示完整的错误消息

[英]NUnit Assert - Display full error message

I have the following assertion: 我有以下断言:

Assert.AreEqual(AssertWelcomeMessage, loginPageModel.WelcomeMessage());

Each variables values are the following: 每个变量值如下:

AssertWelcomeMessage: Hello and welcome to our site! AssertWelcomeMessage:您好,欢迎来到我们的网站! We really hope you enjoy your visit here! 我们真的希望您在这里享受您的光临!

loginPageModel.WelcomeMessage(): Hello and welcome to our site! loginPageModel.WelcomeMessage():您好,欢迎来到我们的网站! We really hope you enjoy your \\n visit here! 我们真的希望你喜欢你的访问!

So the test fails, ok. 所以测试失败了,好的。

When I get the log I see the following: 当我得到日志时,我看到以下内容:

Expected: "...really hope you enjoy your visit here!" 预计:“......真的希望你喜欢这里的访问!”

But was: "...really hope you enjoy your \\n visit here!" 但是:“...真的希望你喜欢你的访问!”

The question is: How can I see the full sentence? 问题是:我怎么能看到完整的句子?

You can't as that is how the developer wrote their code. 你不能像开发人员编写代码那样。

Don't need to see the full sentence anyway. 无论如何,不​​需要看完整句。 They showed you where the difference is. 他们向您展示了差异所在。 There was a line break ( \\n ) in the value returned from loginPageModel.WelcomeMessage() . loginPageModel.WelcomeMessage()返回的值中存在换行符( \\n loginPageModel.WelcomeMessage()

This is the important information needed in the test report. 这是测试报告中所需的重要信息。 The full sentence is of no real value to why the test failed. 完整的句子对测试失败的原因没有实际价值。 The fact that it was not what was expected is the real value of the message. 这不是预期的事实是信息的真正价值。

They would only show you a portion of where they found the difference as showing all of a potentially huge string may cause exceptions. 他们只会告诉你他们发现差异的一部分,因为显示所有潜在的巨大字符串可能会导致异常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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