开发者

MS Unit Testing in VS 2010, Test Method [my method] threw an exception: ..., WT*?

I've got an ASP.NET MVC 2 Web app in VS 2010 and decided to try using MS unit testing stuff. What do you know, on the first test I created it gives me grief and refuses to elaborate.

I have created a single test class and a single test method. I am using Moq to create a HttpContext (including Request, Response, Session, QueryString, Form and Cookies). The method is testing an action on one of my controllers and an exception is occurring in that action when it use MVCs model binding capabilities. However that is not the problem.

When I run the test in VS it simply says: "Test Method [myTestMethodNameHere] threw exception: ..."! So it doesn't give me any idea what the exception is it literally says ... at the end, like a cliffhanger on TV - "... find out in VS 2011, coming soon" 8(.

Debugging the test doesn't help as it's occuring on the UpdateModel(T) line that I'm calling. I am using my own custom binder class but it doesn't get to the breakpoint on the first line of code in that so the exception must be happening in the MVC framework.

I guess this is all a long winded way of asking is there some configuration or code that needs to be written to get the MS unit testing framework to show me the exception in the test results window, is it me or does it sound like 开发者_C百科an MS issue that others have had?

Any help much appreciated, Peter


Right click the failed test in the Test Results pane, and click View Test Result Details. You'll be given a document that specifies the exception, its message and stack trace.

Since you're using Moq, I'm guessing the type will be MoqVerificationException - MSTest unfortunately doesn't pick it up the same way it picks up AssertFailedExceptions, so no nice error messages there...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜