What and When
I will be running my Test-Driven Development and Code Coverage session (for the third time) in Glasgow on the 26th of September 2006. Praise for the session can be found here.
36, Glenfarg Street
Emma Britton via VBUG.
TDD and Code Coverage in .NET
Testing code can be a laborious process that is repetitive in its nature. Empirical evidence confirms that most repetitive processes enjoy a lot of success, or coverage, during early iterations, but later iterations suffer from lower coverage as the tedium sets in. For that reason, we sought to automate the repetitive testing process, i.e. we wrote some code that could replace the repetitive process. The development community achieved this by the adoption of a testing framework that embraced Test-Driven Development (TDD) and testing tools such as NUnit.
The ethos behind TDD and NUnit is “write once, use often”, i.e. once a test has been written it can be used many times. Naturally, by embodying “tests” in code and by using a tool to run those tests, we find the repetitive nature of testing disappears and the process of testing actually beings to provide confidence boosts.
However, whilst adoption of TDD and NUnit provides major advances in the reduction of repetitive testing tasks, they do not help us ensure that the tests actually cover as much of the code-base as is possible/required. It is possible to write a collection of tests that only exercise 25% of the code-base, yet because the tests are successful (i.e. they pass), the developer’s confidence is so high, s/he fails to spot that there is still a lot of test code still to be written.
Code coverage, is not a new technique, the likes of Boris Bezier discussed it in 1990 and Tom McCabe wrote about it as far back as 1976. Today, we can use graphical tools to determine how much of our code is exercised, or covered during an execution cycle. Such tools help us identify which areas of our code have not been tested and can help us direct our effort. However, they do rely on some manual effort that is repetitive, i.e. a user/developer must walk through the application. Luckily, if we are practicing TDD, we have a set of automated tests that we can tap into thus alleviate this repetition.
Over the course of 90 minutes Craig will demonstrate four .net tools, NUnit, NCover, NCoverExplorer and TestDriven.Net. All of these tools and free and work with .net 1.1 and 2.0. A variety of IDEs are supported, include Visual Studio 2003 and Visual Studio 2005. He will explain the basics of TDD and code coverage and why they are both important skills and processes to include in your development/build process. Examples will be written in C# and Visual Studio 2005.
Craig Murphy is an author, developer, speaker, project manager, Microsoft MVP (Connected Systems) and is a Certified ScrumMaster. Commercially, Craig has been using Borland Delphi since 1998; today, he uses Visual Studio 2005 and C#. He regularly writes articles product/book reviews: The Delphi Magazine, International Developer, ASPToday and Computer Headline have published his work. Craig has written for virtually every Developers Group magazine issue since the year 2000! He specialises in all things related to .NET, C#, Borland Delphi, XML/Web Services, XSLT, Test-Driven Development, Extreme Programming, agile methods and Scrum. In his career to date, Craig has written cost estimating software for the oil and gas industry and asset valuation software for local councils and the Ministry of Defence. He has a day-job, a wife and a son.