views:

68

answers:

3

I am using VS 2008 for unit testing. Even if my code calls

Assert.Fail("some message");

Test passess ??

and even

Assert.IsTrue(false); this also passes test.

How is this possible. I am expecting test to fail . i want to forcefully fail it .

Please help !

A: 

Are you using the Assert class built into .NET? If so, I suspect TRACE was not defined.

leppie
How to define trace.
Ajax2020
+1  A: 

Probably you are catching exceptions somewhere in the test code. Assert class uses exceptions to fail the test, so if you are catching it the test passes.

Please paste the code for more accurate answer.

Grzenio
that'd be my guess too - AssertFailedException FWIW
James Manning
A: 

Sometimes, when I click "run tests", I've seen the test engine build in Release configuration but then proceed to run tests against an older Debug configuration build. I would call that a bug in the VS2008 test engine. Anyway, try cleaning your Debug AND Release folders and running it again.

Patrick Szalapski