Fervent Coder

Coding Towards Utopia...by Rob Reynolds
posts - 278 , comments - 431 , trackbacks - 0

My Links

News


Rob Reynolds

Subscribe to Fervent Coder RSS
Subscribe to Fervent Coder by Email

About Me

I manage several open source projects. Need...
   ...package management for Windows?
   ...automated builds?
   ...database change management (migrations)?
   ...your application to check email?
   ...a monitoring utility?

I also write for



Like what you are reading? Want to buy me a cup of coffee?
PayPal - The safer, easier way to pay online!

Article Categories

Archives

Post Categories

Sites

Test Driven Success Story Plus Side Effects of Good Design

Once you understand good design and the benefits, you don't go back.

One of our projects at work has nearly 800 tests in it (across 5 test projects).  The point isn't that we have 100% test coverage (because I doubt we do).  The point is that we know how a method behaves when sent empty and null values, and also for nearly every edge case in addition to the happy path. 

Most of these are 800 tests are logical unit tests. Some are system integration tests (parts of the system working with each other). And few are integration tests (tests that touch resources external to the code such as a database).

We also have an end-to-end project that has a number of black box tests in it that is not included in this number.

Oh, and the project in question is under 2,000 (LOC) lines of code.

This is by far the best designed and adaptable code that I have worked with since I started my career.  We are using NHibernate, IoC (using Windsor Castle Facility), Separation of Concerns, Generics, Interfaces, etc.

I know exactly what I have broken when I refactor the code within seconds.  It allows us to be easily adaptable to changes.  The reason I promote testing and all of the different ideas and components above is because I have been on both sides.  I have worked without any of this, including automated tests.  I know how fast I can respond to changes in my code and how fast I could have responded to changes in the past.  We can respond to changes so fast that the bearer of the work for every iteration is the testing.

In a [coding] world of Semper Gumby (Always Flexible), it's good to have code that is very respondent to change.

What is your success story?

Print | posted on Saturday, August 23, 2008 2:16 PM | Filed Under [ Code ]

Feedback

Gravatar

# re: Test Driven Success Story Plus Side Effects of Good Design

I don't check code coverage on a regular basis. At last note it was somewhere above 90%.

Checking code coverage is only an indicator that you need tests on classes.
8/23/2008 2:19 PM | Robz
Gravatar

# re: Test Driven Success Story Plus Side Effects of Good Design

http://ayende.com/Blog/archive/2008/08/16/Inversion-of-Control-is-NOT-about-testability.aspx

http://jeffreypalermo.com/blog/inversion-of-control-is-not-about-testability/
8/23/2008 2:21 PM | Robz
Gravatar

# re: Test Driven Success Story Plus Side Effects of Good Design

I like to challenge people that are not using any form of testing by asking if I can go change something at random in their code base.

So far that point has hit home with a lot of shops. I am pretty comfortable that any change someone makes will get caught if it breaks something and I will know in seconds.
8/23/2008 3:27 PM | Dave Woods
Gravatar

# re: Test Driven Success Story Plus Side Effects of Good Design

When I say the bearer of the work being testing, I mean the QA testing. We also have work in testing, but it is neglible.
8/23/2008 4:00 PM | Robz
Gravatar

# re: Test Driven Success Story Plus Side Effects of Good Design

@Dave: I might have to try that one next time. I always hear the argument that it is manually tested.

My questions are:
What comfort level does that give maintenance developers?

What comfort level does that give you when you have to make a huge change to the infrastructure? Do you end up tip-toeing around the main parts of the code you should just be changing because you don't want to break existing functionality?
8/23/2008 4:04 PM | Robz
Gravatar

# re: Test Driven Success Story Plus Side Effects of Good Design

I'm currently on a project like the one you describe. We have approx 3500-4000 LoC and just over 1000 unit and integration tests. The confidence that the team has in their ability to change code is remarkable.
On that project we currently have a developer that is working on a new plugin to be consumed by our plugin model. The project architect came to me all excited the other day stating that he was pleased that this developer was almost completed. I asked, amongst other things, if he had any unit tests written. The response was no. I sent the architect back with the comment that no tests meant that he was no where close to being done. As aback as the architect was taken, a quick conversation explaining why our team was succeeding at implementing changes, refactoring code and solid design he left with a much better understanding of the benefit and the reason to push this other developer.
8/23/2008 6:55 PM | Donald Belcham
Gravatar

# re: Test Driven Success Story Plus Side Effects of Good Design

@Donald: The architect???!!!!11111 Um. K. :D

At least you had pull with said architect. I have heard of situations where this was not the case.
8/23/2008 7:32 PM | Robz
Comments have been closed on this topic.

Powered by: