How to debug your program when NUnit is running?

mac2022-06-30  27

How to debug your program when NUnit is running?

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 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/losingmyself/archive/2005/04/28/147064.html

相关资源:JAVA上百实例源码以及开源项目
最新回复(0)