Reputation: 8435
What should I do if I want to show some additional info during the test?
Say I test an algorithm that tries to find a root of a function on the given interval and I want the test to also show the number of iterations it did.
I can add Assert.Inconclusive(_iterations.ToString())
to the end of each test, but that doesn't look good/green.
Upvotes: 0
Views: 315
Reputation: 3385
Use Trace.WriteLine()
. That shows up in your build log.
However, you state "Say I test an algorithm that tries to find a root of a function on the given interval and I want the test to also show the number of iterations it did."
This means you are testing two things. Regardless if you want these two assertions in one test or two, you should still -test- them if that is your goal, not use Trace.WriteLine()
. (You are secretly testing!)
Upvotes: 1
Reputation: 1986
Depending on your test runner you could write info to the console using Console.WriteLine()
. If you run your tests from command line (nunit-console) this will make it messy while using ReSharper it will look ok.
Upvotes: 0