Is there a way I can add a custom message to the result of a test method? I want to put a stopwatch on part of the code to see how long its running. I don't need to test that it's running within a certain time frame, just want to see in the result window what the elapsed time was.
The simple answer is because you have to shoehorn the test into those three steps. So get rid of those comments. They serve no useful purpose and the test is easier to read without them.
To generate unit tests, your types must be public. Open your solution in Visual Studio and then open the class file that has methods you want to test. Right-click on a method and choose Run IntelliTest to generate unit tests for the code in your method. IntelliTest runs your code many times with different inputs.
Assuming you are using MSTest, you can use
System.Diagnostics.Trace.WriteLine("Hello World");
To output whatever you'd like. It will show up in the full results of the test runner.
The example above did not work for me but the following did:
var result = routeManager.UpdateWalkingOrder(previouspremiseFuncLoc, premiseFuncLoc, out message); Assert.AreEqual(true, result, message);
Where message is any error i want to display in the Error Message Dialog of my Test Result. In the example above I am returning errors that are captured when executing that function and showing it in my test results which is great help for debugging.
In your case you could just display the running time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With