.NET unit tests - Assert.IsTrue message?
I'd like to add a message to be displayed in Visual Studio 2010 test results.
I can post a message out if the test fails, but not true. Is there anyway to do this?
For example:
dim quoteNumber as string = Sales.CreateQuote(foo)
assert.IsTrue(quoteNumber <> "")
'I would like to make this something like this:
assert.isTrue(quoteNumber <> "", falsepart, "Quote number " & quot开发者_运维知识库eNumber & " created")
I don't know what unit test framework you're using, but with the Visual Studio unit tests, you can do the following:
Assert.IsTrue(quoteNumber <> "", "Quote number must be non-empty")
'I would like to make this something like this:
Console.WriteLine("Quote number " & quoteNumber & " created")
Your best bet may be to use Console.WriteLine(). NUnit captures anything written to the console to another tab in the GUI. I would assume that VisualStudio's test runner would do the same.
I think you are looking for Assert.IsFalse
. Maybe
Assert.IsFalse(quoteNumber = "", "Quote number " & quoteNumber & " created")
精彩评论