Friday, August 19, 2011

Trying to get used to MSTest.

Some of our data tests won't work with Resharper so I have to rely on MSTest which I am getting used to. If one does an assert like so...

Assert.IsTrue(unlucky == 13);

 
 

...and the test fails on the assert, one will only see that the test failed (in the "Test Results" pane) on the assert and not what the...

Oh, wait, as I type this I realize that I should really use:

Assert.AreEqual(unlucky,13);

 
 

...as otherwise there is no way to see what the value compared to 13 is when the test fails (Duh) unless one does something like this...

Assert.IsTrue(unlucky == 13, unlucky.ToString());

 
 

The second parameter above is a message to give in the case of a failing test.
Other things to mention...

  1. in the "Test Results" pane, right-click on a test and select "View Test Results Details" to see further specs
  2. one may set breakpoints in a test in Visual Studio and then run the test and stop at the breakpoints... set a breakpoint, and then Ctrl-F+T at the top of the test method to run the test

No comments:

Post a Comment