MSDN Magazine - February 2008 - (Page 15) framework compared with the existing .NET unit-testing frameworks. Most notable are the features that have been removed—in an effort to simplify the framework and the tests written using it, a number of attributes that are present in many testing frameworks have been removed. To make tests easier to read and understand, there are no setup or teardown attributes—all initialization and teardown code must be done in the individual tests. The idea behind removing these attributes is that they only make it harder to understand what exactly a test is doing because the logic can be split over three different methods. By removing the setup and teardown attributes, Newkirk and Wilson are encouraging developers to put all of the logic for their tests into the single-test method. The ExpectedException attribute is gone in favor of a new method on the Assert object called Throws. The Throws assertion allows the developer to be more explicit in specifying where the expected exception will come from, making false positives less frequent. TestFixtureSetup and TextFixtureTeardown have been replaced with an ITestFixture interface. The Ignore attribute has been removed and instead implemented as a property on the Test attribute. xUnit.net is not just about removing features, though—a number of very useful features have been added to the framework as well. xUnit.net includes complete support for generics and anonymous delegates, which make tests more concise and accurate. Also, xUnit.net includes the ability to extend the functionality of the framework using custom comparers, custom test methods, and custom classes. There is no GUI testing tool included with this release of xUnit.net, only a console runner and Visual Studio support using TestDriven.net. I would not recommend dropping your current testing framework for xUnit.net keep your eye on, even if only to learn from the great ideas and best practices being put forth through this tool. Price: Free; source code available. codeplex.com/xunit Pragmatic Unit Testing It may be easy to get started with unit writing unit tests, I had only a couple of blog posts and articles to guide me—I sure wish I had a book like this to refer to then. Pragmatic Unit Testing in C# with NUnit Andrew Hunt and David Thomas is the second volume in a three-volume series titled The Pragmatic Starter Kit. The trol, and the third volume covers project automation. Pragmatic Unit Testing covers the basic ideas, of unit testing, as well as the planning and writing of unit tests. The book uses NUnit for its examples, but the theories apply to just about any of the unit-testing frameworks available for .NET. Offering a wealth of practical advice on testing, this book is both an excellent introduction to unit testing and a great guide on how to write better unit tests and solve common testing issues. Price: pragprog.com/titles/utc2 *]QTL QV\MZIK\Q^M LQIOZIU[ MI[QMZ \PIV aW] M^MZ QUIOQVML 8W_MZN]T Ð M`QJTM IVL MI[a\W][M ,W_VTWIL ?Q\P .]TT ;]XXWZ\ cVReV Tfde`^ Z_eVcRTeZgV UZRXcR^d _Veh`c\ VUZe`cd h`c\W]`hd W]`hTYRced R_U UVdZX_ e``]d 7`c hVS dVcgVcd `c ]`TR] Raa]ZTReZ`_d :e|d VRdj e`fdV R_U gVcj W]ViZS]V HV|cV eYV WZcde UVgV]`aVc `W UZRXcR^^Z_X T`^a`_V_ed R_U deZ]] eYV SVde 7Z_U `fe W`c j`fcdV]W+ U`h_]`RU `fc 7C66 Wf]]j Wf_TeZ`_R] VgR]fReZ`_ \Ze hZeY Wf]] dfaa`ce Re hhh_h``UdT`^ .:-- Send your questions and comments to toolsmm@ microsoft.com. James Avery runs his own .NET consulting practice,Infozerk Inc. He has written a number of books and articles, and his most recent book is Visual Studio Hacks (O’Reilly, 2005). You can e-mail James at javery@infozerk.com and read his weblog at www.dotavery.com/blog. All prices were confirmed at press time and are subject to change. The opinions expressed in this column are solely those of the author and do not necessarily reflect the opinions of Microsoft. Toolbox february2008 V_WWL[KWU 15 http://codeplex.com/xunit http://pragprog.com/titles/utc2 http://www.nwoods.com http://www.dotavery.com/blog http://www.nwoods.com
For optimal viewing of this digital publication, please enable JavaScript and then refresh the page. If you would like to try to load the digital publication without using Flash Player detection, please click here.