Instead of βOne test for each function,β think of it as βOne aspect of behavior for each function.β
What adds you an object? How about deleting an object? Why are they valuable? How can you say that you made them? Write an example of code usage and why this behavior is valuable. This will be your test.
When you figure out what kind of behavior you are interested in, extract duplication only if it makes the test more readable. TDD is not only testing; it is also about providing documentation and will help you think about the responsibility of each element of the code and the design of that code. Tests are likely to be read much more than they are written, so readability should be the first.
If necessary, put all the behavior in which you are interested in one way and just make sure that it is readable. If necessary, you can add comments.
source share