简体   繁体   中英

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. What additional steps need to be taken for me to see "blah" in the "Text Output" tab of NUnit?

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 . In this case 1==1 is true hence it's not going to show.

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

should do the trick.

Simply use Console.WriteLine("yourtext") to display any text in the TextOutput tab.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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