DevPinoy.org
A Filipino Developers Community

>>> First two to make 3 wins! <<<

ExpectedException vs Testdriven.Net's easy VS code navigation
I was using MbUnit in my expression evaluator when i noticed that a failing test with an ExpectedException does not include a link to the line of the failing code.  The link is established if you are on a DEBUG build (i encountered not seeing a link since i am on a RELEASE build, no pdbs) since the code at fault will be included in the stack trace so you just double click in your output window and you'll get a marker in code view.  The primary purpose of using testdriven.net with visual studio is to easily navigate from the failing tests output window report to the code at fault but i noticed no link with a failing ExpectedException:

Starting the MbUnit Test Execution
Exploring UnitTests, Version=1.0.2459.29151, Culture=neutral, PublicKeyToken=null
MbUnit 1.0.2445.37068 Addin
Found 1 tests
[failure] CalculatorTests.Setup.Evaluate_RaisesUndefinedExceptionForUnknownFunctions
TestCase 'CalculatorTests.Setup.Evaluate_RaisesUndefinedExceptionForUnknownFunctions'
failed: Exception of type MbUnit.Core.Exceptions.ExceptionNotThrownException was thrown. Expected exception of type Exception of type MbUnit.Core.Exceptions.ExceptionNotThrownException was thrown., did not get it.
    MbUnit.Core.Exceptions.ExceptionNotThrownException
    Message: Exception of type MbUnit.Core.Exceptions.ExceptionNotThrownException was thrown. Expected exception of type Exception of type MbUnit.Core.Exceptions.ExceptionNotThrownException was thrown., did not get it.
    Source: MbUnit.Framework
    StackTrace:
    at MbUnit.Core.Invokers.ExpectedExceptionRunInvoker.Execute(Object o, IList args)
    at MbUnit.Core.RunPipeStarter.Run(Object fixture)


Without this link, you just have to rely on the failing test's method name.  I also found out that this problem is also persistent with NUnit.  Obviously the method is not part of the stack trace since it was just invoked through reflection.  If you are coding an ExpectedException test case using the classic try-catch-Assert.Fail combo, you'll be lucky with the code link since the Assert.Fail will be part of the stack trace.

Posted 09-25-2006 5:22 PM by jokiz
Filed under: ,

Copyright DevPinoy 2005-2008