unit testing - Debug.Assert interferes with MSTests, how do I work around it? -


So I have been testing a unit through MSTests to ensure that it comes to bad data Excludes exceptions correctly. / P>

However this is debug in this method. Associate while debugging while this is during actual testing, where I am trying to find a bug in debug mode.

Therefore, the unit tests fail to be automatic when run in this way, because the ashert comes with abort, retrieve, ignoring statement. All 3 positions are important:

I'm looking for debugging and a problem, so I should debug. Attachment code should be appropriate guard clause to be available, so if the exception is in production, the exception is thrown.

So far when the unit tests are being run locally, Nicole's solution I wanted Did not, because I intentionally passed the values ​​that would travel in. To make sure the exception is thrown, intervene with running the automated unit test at the local level. I think that this would work if I was ready to accept the code and the Conditional ("DEBUG") compilation feature and run the unit test in release mode. If I want that behavior I can provide a test level (or assembly level) with the wrapper [conditional ("debug")] in the test assembly, but it can be used from one I Are a pre-compiled reusable class library.

With the additional requirement to call Trace, this goes very close to what I want. Listener Clear (); In my test suite.

  /// & lt; Summary & gt; To use messages to suppress the ///use, use: ///. Trace.Listers. Clear (); /// & lt; / Summary & gt; /// & lt; Typename name = "t" & gt; & Lt; / Typermum & gt; /// & lt; Param name = "assertAgainst" & gt; & Lt; / Param & gt; /// & lt; Ultimate name = "status" & gt; & Lt; / Param & gt; /// & lt; Param name = "exception" & gt; & Lt; / Param & gt; /// & lt; Returns & gt; & Lt; / Returns & gt; Public static tee & lt; T & gt; (The T assertAgainst, the event's & lt; exception & gt; exception of the function & lt; b; condition;); var conditionMet = assertAgainst; If (debugger .idadet) debug Asset (condition mate); //assertAgainst.Assert (x => x! = Null, () => New NullReferenceException ()); Exclude (! Condition Mate) Exception (); Come back; }  

Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -