Testing Obsolete Methods

I was at the TDD Workshop today and got my perspective adjusted on the matter of Unit Testing.

As I was trying to attack the method in my mind from different angles on my way back home, I came to the question of using Unit Tests on methods marked as Obsolete.
After all, Unit Tests are supposed to check that your code is all right whenever you run them. If your code uses Obsolete methods, this means that soon enough, it might not run and even not compile. Using nightly builds with unit tests will not reveal this matter, since using an Obsolete method raises only a faint warning.

Consider the following:
The Red Team is the infrastructure team for The Blue Team at Gulch inc.
The reds decide one day that they are going to refactor their code and decide to kick some methods out the door. Like every other polite team, they decide to keep the old methods, but place an ObsoleteAttribute on them.
The blues get the new set of assemblies and run all of their unit tests on them to see that their code is still all right. It is, since the Obsolete methods still run, but it’s not okay to use them.

I think that if the unit tests would warn in a way (or even fail), that the code uses an Obsolete method, nightmares like the ones Raymond has would just not occur (yes, only for people who use Unit Tests, you cynics ;).

What do you say?


One thought on “Testing Obsolete Methods

  1. If the red team is gonna change its interfaces with blue team in the future, it should notify the blue team about those changes. Obsolete is step one, and more steps are required, some are code changes.

Leave a Reply

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 )

Google+ photo

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

Connecting to %s