Defining the Right “Unit” in Unit Testing

One of the most discussed question when people talk about unit testing is what a “unit” is? In this blog post, Ken Baltrinic tries to answer this question.

The post starts by putting the problem of defining unit testing in the context of class refactoring. This lead to the idea that test should target elementary business function and not try to test implementation as this will lead them to break more easily. The post explores how to put this in perspective with Test-Driven Development (TDD) where you shouldn’t start writing code before you have a failing test to verify it. The post is a very interesting discussion about the level of unit testing.

The conclusion of Ken Baltrinic is “I will conclude by admitting that I have not truly answered the question I started out with. How do we correctly define a unit? I have asserted that the best definition of a unit “the code that implements the lowest level business function.” In short we need to be able to discern the boundary between business function and implementation detail.”

Read the full blog post on http://blog.baltrinic.com/software-development/agile-practices/automated-testing/unit-testing-defining-the-right-unit