2

Can anyone tell if finally is always executed after a test times out or not.

[Timeout(1000)][TestMethod]
public void test()
{
  try
  {
     System.Threading.Thread.Sleep(2000);
  }
  finally
  {
     //do something
  }
}
waterbear
  • 69
  • 1
  • 11

2 Answers2

0

Finally is executed always, doesn't matter if u have try/catch/ block, it is executed when any of those are finished

Gustav Klimt
  • 430
  • 3
  • 14
0

If possible, use the TestCleanUp method in order to do work after the test if it is subject to timeouts.

Keysharpener
  • 486
  • 3
  • 14
  • Sorry, not enough reputation to add a comment to Schaliasos's answer. As far as I know, Test Timeouts do not apply during Debugging sessions. – Keysharpener Nov 22 '12 at 14:42