Where's my road?

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

When errors occur in a unit test by making use of NUnit, we may want to debug the program immediately to see where the error occured. But the problem is that it's difficult to enter visual studio's debugger when a unit test is running.

.Net provide us Debugger.Break(System.Diagnostics.Debugger) to solve the problem. You can place a Debugger.Break statement wherever needed. When NUnit executes to the statement, you'll be asked to attach a debugger. If a debugger has already been attached, the statement will be just ignored. Then you can debug your program :)

Sample

[TestFixtureSetUp]
public void Initialize()
{
  .
  Debugger.Break();
  .
}


[Test]
public void YourCustomizedTest()
{
  .
  Debugger.Break();
  .
}

posted on 2005-04-28 17:13  Lin  阅读(1352)  评论(3编辑  收藏  举报