xUnit Assert in Step Definitions vs. TargetInvocationException

Apr 17, 2013 at 11:31 PM
Hi TickSpecers,

I'm calling xUnit Assert methods in my step definitions. For example Assert.Equals(1, valueThatShouldBeOne). This all works well. However, when they fail, the Exception details I see in the ReSharper unit test runner Output window is the TargetInvocationException from the reflection Invoke, rather than the Assert details.

Is there a way I can configure TickSpec to show me the underlying Assert exception and stack trace details (so I can know what is failing)?

I've built a modified version locally that gives some basics on the InnerException, but I thought I would ask what your thoughts/advice is on this before working on a full change.

Thanks for building TickSpec. I like using it!

Apr 18, 2013 at 8:48 AM
I have a simple workaround for this which works with TestDriven.Net and so may well work on ReSharper (please let me know).

In the reference implementation of TickCommand when an exception is caught in a step method it creates a FailedResult with the root exception and stack:
FailedResult(info, ex, scenario.ToString()) :> MethodResult 
Changing it to report the inner exception should give the stack trace starting at the step method:
let ex = if ex.InnerException <> null then ex.InnerException else ex
FailedResult(info, ex, scenario.ToString()) :> MethodResult 
Thanks for the feedback :)

Apr 18, 2013 at 4:48 PM
Thank you Phil. Worked like a boss with ReSharper too. Easy and simple to boot!

Loving the TickSpec.