When testing with Visual Studio Team Test unhandled exceptions in tests are caught and reported in the results. So I was kind of surprised to see the test hosting process (VSTestHost.exe) crash and showing the system crash dialog.
Upon further investigation this crash was an unhandled exception raised in another thread (more directly, it was an async socket callback). And indeed something like this crashes the hosting process:
[TestMethod]
void Test()
{
new Thread(() => { throw new Exception(); }).Start();
}
Any advices what I should do there?
- Should I just live with it, saying any code distributed/checked-in should be tested at least once anyway, and so such things most likely will be caught?
- Should I try to install a global exception handler and check its status in every tear-down method?
- Or maybe there are already exists stuff helping with this?