dotNetDave Says… If Your Code Is Hard To Unit Test, You’re Doing It Wrong

Unit testing is something very important for any project. With that said, I rarely see it done in projects or done correctly. How can you push the code to quality assurance or production without knowing the state of the code?

A few years back, I worked on a contract at a company here in San Diego, California. The two managers came to me after I started and said they were going to give me access to the production servers so I can push code. I asked them if there are unit tests for the projects. They said no. So I told them I don’t want to be responsible for pushing to production unless there are. I didn’t last there very long (for other reasons too).

Let’s face it, I don’t think anyone wants to write unit tests, they aren’t features and they don’t sell product. But, they are very, very important. From talking to people who work at Microsoft, try to make it a goal to have at least 75% of code coverage.

Look at it like going to the doctor for a check-up. Sure, I don’t think anyone looks forward to it, but it needs to be done to know the state of your health. Unit tests are the same thing.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

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

Google photo

You are commenting using your Google 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

This site uses Akismet to reduce spam. Learn how your comment data is processed.