Archive

Archive for the ‘Continuous Integration’ Category

Automation to the rescue (again) for newbie TDDers! (NCover)

February 22, 2004 12 comments

My current project (which I am very excited about!) is building an internet facing ASP.NET application for a high profile function. It involves building business objects to map to the database and general functions of the system and then mapping those into the UI. And now the fun part … the entire application has been built using TestDrivenDevelopment (TDD)!

The business layer is being developed test first using NUnit and likewise in the ASP.NET UI using NUnitAsp. The rest of the architecture:

  • SourceGear Vault for Source Control
  • Visual Studio .NET 2003
  • DAL – Thycotic.Data
  • Business objects – hand coded (with the help of a custom rolled generator) and using NullableTypes for exposed properties
  • NAnt script for pulling out of Vault, compiling, running NUnit unit tests and pushing successful builds to integration server (running every 30 mins on a scheduled task – CruiseControl.NET doesn’t support Vault yet …)

What is the problem? TDD is new to the other developers and management. This means that occassionally there is a tendency to not test drive and just add a feature (null check, private method, etc) without a failing test. If we were always pair programming this would be less of an issue but our deadline is too tight to lose the estimated 15% additional time required to pair program. We did pair program on really critical areas of the system – base objects, establishingour data access pattern, exception managementand security. However, the areas of missed TDD code are a great risk as they stand the best chance of containing bugs and swallowing developer time (and this has already been experienced on a few occassions).In true XP style we need an automated tool to help us catchany lack of coverage …

Enter NCover!

  • Integrates with our NAnt process (copy the source tree, instrument it, run the unit tests, generate a coverage report)
  • Provides a metric that we can track and makes management happy by giving them numbers to confirm the TDD process (example reportfrom the NCover website)
  • Points us towards the code of least coverage (and greatest risk) to allow us to either delete it (dead code) or write a test for it (not the nicest … but better than not having a test!)
  • It is automated and provides continuous feedback with no intervention required once configured

I am very impressed by NCover. We have looked at the code (which compiled and passed all its unit tests right after the download!) and it is reallyneat. Well done to the developers! It would be nice to know the coverage strategy it is using (it uses a set of regular expressions at the moment to find branches in C# code) … after looking at the instrumented code, it may need a little tweaking to catch all possible execution paths but it is an amazing and very welcome product.