You have been given the task of creating some business objects for a new .NET project. The UI has not been created (or designed) yet, so you start coding right away. After creating the first few objects, you decide that maybe you should do some unit testing. This article shows you how.
by Dan Jurden
Dec 13, 2004
Page 6 of 6
It is possible to use the NUnit GUI as the debugging application in your .NET project. Even though your project does not have a UI, you can run your business object project. This allows you to set a breakpoint in either your TestFixture code or your business object code. When the testing process hits the breakpoint, you'll be able to step through your code using the .NET debugger. To set this up, follow these steps:
Right-click on the project in your solution and select Properties.
In the Property Pages window, expand the Configuration Properties folder.
Select the Debugging option.
In the Start Action group of properties, change the Debug Mode property to Program.
Click the Apply button.
Now click on the ellipsis to the right of the Start Application properties and navigate to and select nunit-gui.exe.
After going through this process, you can set a breakpoint and press F5 to start a debugging session. After compiling your project, the NUnit GUI application starts. Click on the Run button. When the test process gets to your breakpoint, you will be able to use the debugger.
The NUnit framework is an excellent tool for testing business objects. It is very easy to construct test cases to test calling methods on a business object with several different parameter values to make sure that the methods return expected results each time. It is also capable of detecting expected exceptions; if you call a method in a way that you expect to throw a specific exception, you can test for this also.
Dan Jurden is a Senior Application Developer for EPS-Software Corp. He is a Microsoft Certified Professional and co-authored the book "Creating Visual FoxPro Applications Using Visual FoxExpress" with Bob Archer, published by Hentzenwerke Publishing. Dan was also the Technical Editor for "CrysDev: A Developer's Guide to Integrating Crystal Reports," also published by Hentzenwerke Publishing. He has authored articles published in CoDe Magazine, Fox Talk, MSDN Brazil, SDGN Magazine, and Universal Thread Magazine, dealing with SQL Server, .NET, MySQL, VFP, and other topics. Dan has presented topics at the German DevCon, Essential Fox, SQL Server Live!, SDC Netherlands, and GLGDW conferences. He has been developing client/server applications using SQL Server Crystal Reports for over eight years.