您的位置:首页 > 其它

How to debug your program when NUnit is running?

2005-04-28 17:13 681 查看
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()

[Test]

public void YourCustomizedTest()

    Debugger.Break();

  }



内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: