Thursday, March 10, 2005

10 ways to make your code more testable.

You know you have to write unit tests. You have the tools, and your team is committed to the idea. Somehow, though, despite your best intentions, the tests just never get written. Or you write them, but never run them. They always fail anyway. For one reason or another, your project is resisting the will of the unit test. Usually, this means that your code needs a good solid refactoring, to make it more accepting of the way of the test.

Facts discussed include.
Use Interfaces,Define a base test class,Make everything return a value,Separate data access from business logic,Make use of configuration,Make Your Classes Do Only One Thing...

Read More