I’m wondering what the best practices are in Test Driven Development / testing using unit tests when it comes to increasing features.
E.g. I have a requirement when an object of Class Foo receives a bar() message, it should update a given field counter accordingly. I create a test case for this, which creates a Foo object and then tests the requirement.
Now what should I do if there is a new requirement, that when Foo receives a bar() message also another field, counter2 should be updated. Should I create a new test case for this, which checks only the second requirement, or do I just update the first test case?
Seems that your question contains the answer. From my practice, if it’s a new requirement, which doesn’t change previous one, then you should create a new test for it. If it’s a change of requirements — then you should modify old test, to fit these updated requirements, and do it prior to implementation.