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

Published Sunday, February 22, 2004 8:17 AM

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, establishing our data access pattern, exception management and 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 catch any 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 report from 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 really neat.  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. 

Comments

# Paul Wilson said on Sunday, February 22, 2004 9:47 AM

Sounds like a cool project. I'm wondering what Thycotic.Data really added though, since its pretty easy to code against the data interfaces already -- without the late binding performance hit! Anyhow, it does sound very cool to actually get the opportunity to do software right for once.

# Steven Smith said on Sunday, February 22, 2004 11:12 AM

Hmm, apparently it also requires eclipse (at least in the default nant script), at c:\tools\eclipse3M6\...\.

So much for building on the first try. Looks pretty cool, though - definitely going to have to get it working.

# Steven Smith said on Sunday, February 22, 2004 11:27 AM

Ah, figured it out. The expectedCoverage.xml file that comes with the 0.7 download has those c:\tools\eclipse paths in it. Remove that and run
nant selfbuild

instead of just 'nant' or 'nant build' and it works (42.86% coverage out of the box, it says).

Now to get it running on one of my projects...

# Jonathan Cogley said on Sunday, February 22, 2004 5:25 PM

I never said "build" :-)

I said compiled and passed all its tests ... I was using the VS.NET IDE because I was looking at the code to see how it works.

# Johnny Hall said on Monday, February 23, 2004 12:17 PM

I'm interested in hearing more about your experiences with Vault, nAnt, nUnit and CruiseControl.NET.

This is exactly the setup that I am considering for future projects. At the moment, I'm working on a one-man project, so I'm building with VS.NET. However, I want to set up CruiseControl and nAnt for all future (group) projects as well as moving to Vault (I've crossed the line with VSS).

However, I was a little concerned about the lack of Vault intergration with nAnt and CC.NET. How did you find the integration issues? Are your scripts complicated?

Do you know when CruiseControl may or may not be integrated with Vault? I know that some work has been done to create nAnt tasks for Vault. Any experience?

# Christian Romney said on Wednesday, April 7, 2004 6:39 PM

Shoot,
CruiseControl.NET is open-source, why don't a few of us just write the darn Vault integration? Takers?

# Thibaut Barrère said on Wednesday, June 2, 2004 6:00 AM

Additional disclaimer : I have not tested CCNet + Vault myself ;)

This Blog

Syndication