开发者

Testing increasing features with unit tests

开发者 https://www.devze.com 2023-02-23 04:59 出处:网络
I\'m wondering what the best practices are in Test Driven Development / testing using unit tests when it comes to increasing features.

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 requireme开发者_C百科nt 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.


I would generally add a new test case, so that the two features are kept independent in testing, and which test fails indicates which feature is wrong.

0

精彩评论

暂无评论...
验证码 换一张
取 消