Friday, November 02, 2012

Test Clean-Up

I've recently had a massive clean up of dependencies between our Core solution, tests & everything else that comes to mind.

During this time I noticed a number of tests which fell in to the following categories:

WTF?  Are they testing!
They've been in our test suite & build server for a long time in there current guise.  The first set are similar to:
public void BuildMeAPanda()
     var panda = new Panda("Chi Chi");
     Assert.That("Chi Chi", panda.Name);

As you can see we are simply testing the logic of a constructor.  Not too much value in this.  Although it looks good on our code coverage stats!!!  

The second are ignored tests which seem to have been written with a future intend - i.e:

[Test, Ignore("Really need to work out how to test this!")]
public void InteractWithDb()
    var panda = new Panda();
    var repo = new PandaRepository();
    // work out what to do here!

Broken & [Ignored]
The third are the they broke the build, I must get the build in, quickly ignore the test ones:
[Test, Ignore("This breaks the build I'll re-instate it later")]
public void Bug52358()
    // Arrange 
    ... Lots of code
   // Act
   ... Some more code
   // Assert
   ... Some assertion

My view on these tests is to eradicate them.  If they've not been in your build cycle for some time then they are not adding any value.  They are simply adding overhead to your build time, your thoughts and general clunk within your solution.

I would also try to re-instate the Broken but ignored tests, however, if they fail and you can't understand them within a time boxed amount of time delete them...

The only occurrence that I've not done this - is on those integration tests where you use them occasionally - a prime example of this is testing email & sms sends.  However, these should appear in a different project called:
  • .IntegrationTests
They should be clearly labelled with:
  • [Ignore("Integration tests!")]

And over time you probably want to delete these too!?!


hanry gill said...

thanks for sharing help full information

software product development

vijitha said...

Great thoughts you got there, believe I may possibly try just some of it throughout my daily life.
Software Development