Real experience of adding first sets of Tests to existing code base

I recently joined a team of very skilled and talented people. We wanted to put in Tests for an application which was running in production for quite some time. I cannot specify the details of the project but it had tens of thousands of line of code in it. It was developed in Microsoft Dot Net and SQL Server and a web application.

I would like to share some insight and recommendations:

  1. Long running tests and writing long dependency tests setups is the norm
  2. Adding technical debts in tests will be needed but keep it as clean as possible.
  3. Don’t worry of Unit Tests in the beginning. It will be lot harder to do it.(Add Integration tests, refactor code in smaller units, add unit tests later)
  4. Some types of test that will help you during this initial testing phase :
    1. Pinning Tests : http://c2.com/cgi/wiki?PinningTests
    2. Characterization Test : http://c2.com/cgi/wiki?CharacterizationTest

You must be thinking you already know all this stuff above. But the view point I want to share here is some real world numbers and facts. Firstly add  a automated code coverage to get the results of your tests with just one click. (a simple .bat file worked for me)

  1. I was working with the code for first time.
  2. It took me 16 hours to put in first 6 tests.
  3. These where clean, re factored and commit ready to Git.
  4. Code Coverage was 6% after 6 tests.
  5. When I added 5 more tests the code coverage was 15%
  6. Tests were covering different classes of different modules.

This stats may be controversial and its true that code coverage doesn’t signify that your code has 100% automated tests for all possible scenarios, However here are some reasons to go with it.

  1. It give some numbers to go for during initial stage of adding tests.
  2. It will help you to add test harness for different areas of applications.
  3. You can share reports with team and get feedback on what’s next.

Happy Coding!

Advertisement

Leave a comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: