Home Dashboard Directory Help
Search

VS Unit Tests: It is not possible to activate the runtime settings ThrowUnobservedTaskExceptions. by omjbe


Status: 

Active


4
0
Sign in
to vote
Type: Bug
ID: 790351
Opened: 6/17/2013 10:26:15 PM
Access Restriction: Public
0
Workaround(s)
view
1
User(s) can reproduce this bug

Description



.NET 4.5 changed the exception handling behaviour of Tasks which caused us a lot of trouble. Now the unobserved exceptions are ignored whereas in .NET 4.0 the finalizer of the Task has thrown them.

It is possible to reactivate the “old” behaviour with the runtime configuration ThrowUnobservedTaskExceptions. This works for our WPF applications but I have not found a way to do the same with our unit tests.

At the moment a unit test can pass although a Task has thrown an unobserved exception. It is possible to define an “App.config” file for unit tests as well. But it seems that runtime settings are not applied.

How can I activate the ThrowUnobservedTaskExceptions behaviour in our VS unit tests?
Details
Sign in to post a comment.
Posted by omjbe on 7/31/2013 at 11:13 PM
@Microsoft: Please provide me some information if you close the bug. I have still not found a way to activate the ThrowUnobservedTaskExceptions behaviour in our VS unit tests.

If you close the bug with the reason “As designed” then please show me some workaround. Thanks.
Posted by omjbe on 6/20/2013 at 10:57 PM
Unfortunately, this does not work. The unit test sample in steps to reproduce is just a simplified sample to reproduce the issue I have. These unhandled exceptions are called inside an external library and there is no way to handle the exceptions myself.
Posted by Microsoft on 6/18/2013 at 2:35 AM
Thanks Omjbe for your feedback.

To wait for the task to complete, you should use return the Task object from the unit test as shown here.

http://blogs.msdn.com/b/visualstudioalm/archive/2012/03/13/what-s-new-for-mstest-unit-tests-in-visual-studio-11-beta.aspx

Please try it out and do let us know in case it does not work for you.

Regards
Visual Studio Product Team
Posted by Microsoft on 6/18/2013 at 2:00 AM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by Microsoft on 6/17/2013 at 10:50 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Posted by omjbe on 6/17/2013 at 10:30 PM
More information can be found in the MSDN Forum Post: http://social.msdn.microsoft.com/Forums/en-US/vstest/thread/b79099e9-ea91-4700-8a6f-fe91cbd846c1
Sign in to post a workaround.