Testing advanced features with unit tests

I am wondering what is best in Test Driven Development / testing, using unit tests when it comes to increasing capabilities.

eg. I have a requirement that when a Class Foo object receives a bar() message, it should update this counter field accordingly. I create a test case for this, which creates a Foo object and then validates it.

Now what should I do if there is a new requirement, when Foo receives the message bar() another field, counter2 should be updated. Should I create a new test case for this that only checks the second requirement or am I just updating the first test case?

+6
source share
2 answers

Your question seems to contain the answer. From my practice, if this is a new requirement that does not change the previous one, then you should create a new test for it. If this is a change in requirements, then you must modify the old test to meet these updated requirements and do so before implementation.

+8
source

Usually I add a new test case, so that the two functions are independent of testing, and which test is not displayed, indicates which of the functions is incorrect.

+3
source

Source: https://habr.com/ru/post/885502/


All Articles