.NET unit tests - Assert.IsTrue message?

I want to add a message that will appear in Visual Studio 2010 test results.

I can post a message if the test failed, but not true. Is there any way to do this?

For instance:

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 " & quoteNumber & " created") 
+4
source share
3 answers

I don’t know which unit test structure you are 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") 
+3
source

It is best to use Console.WriteLine (). NUnit commits everything written to the console to another tab in the graphical interface. I would suggest that the VisualStudio tester do the same.

+1
source

I think you are looking for Assert.IsFalse . May be,

 Assert.IsFalse(quoteNumber = "", "Quote number " & quoteNumber & " created") 
0
source

Source: https://habr.com/ru/post/1340386/


All Articles