简体   繁体   English

Assert.True 消息未显示在 NUnit GUI 中?

[英]Assert.True Message Not Showing In NUnit GUI?

Assert.True(1==1, "blah");

When this code runs, "blah" does not appear in the NUnit GUI.当此代码运行时,“blah”不会出现在 NUnit GUI 中。 What additional steps need to be taken for me to see "blah" in the "Text Output" tab of NUnit?我需要采取哪些额外步骤才能在 NUnit 的“文本输出”选项卡中看到“blah”?

The message doesn't appear because the assert is valid.该消息未出现,因为断言有效。 The Assert.True method checks to see if the expression is true and displays the message only if it's false . Assert.True方法检查表达式是否为 true 并仅在为false时显示消息。 In this case 1==1 is true hence it's not going to show.在这种情况下1==1true ,因此不会显示。

Assert.True(1==0, "blah");

should do the trick.应该做的伎俩。

Simply use Console.WriteLine("yourtext") to display any text in the TextOutput tab.只需使用Console.WriteLine("yourtext")TextOutput选项卡中显示任何文本。

This has the added benefit (as opposed to the other answers) of not to mess with your test results, which is most propably what you want.这有一个额外的好处(与其他答案相反),不会弄乱你的测试结果,这很可能是你想要的。

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

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