Assuming we are implementing using TDD a Stack
class, we would need, for each bit of functionality of our Stack class, to add a new test that exercises it:
[TestMethod] public void Should_Be_Empty_After_Instantiation()
[TestMethod] public void Should_Not_Be_Empty_After_Pushing_One_Item()
...
Now, on the other hand, when doing Unit-Tests, one should focus on what external behaviour our class is supposed to provide, so the set of Unit-Tests check that all the expected contracts for my Stack interface are fulfilled.
My question is in how to conciliate those two aspects.
For example, assuming my Stack
uses internally an array with an initial size of 8, I'll want it to grow if my user wants to insert a 9th item. For adding that resizing functionality, I'll want to have at least one test that drives my class code in that direction (am I right?).
On the other hand, that would be adding a Unit-Test (or isn't this really a Unit-Test?) that exercises not the actual contract of the class(I am assuming the user doesn't care for the internal implementation of the Stack) but its implementation.
So we have a twist here, that I don't know how to solve. Am I making any confusion of concepts here?
Thanks
Edit
After much googling I came to the following link that seems to deal with this issue: http://stephenwalther.com/blog/archive/2009/04/11/tdd-tests-are-not-unit-tests.aspx