1

I'm extracting a new class, should I create new tests for it? I'm wondering as to how to realize when to create new test and how to implement them when they are needed.

1

Test Driven Development (TDD) means that you write your tests before you write your code. So if you identified your class should be extracted from others there must be an individual reason to do so. So you should at least write tests for this individual functions.

Depending on if you already have tests for the common functions of your class you (don't) need to write these tests too.

| improve this answer | |
0

Every class with implementation has its own responsibility and behavior. So it is good to implement test that represent the class's behavior.

| improve this answer | |
0

Yes. Though to help make it easier on yourself, if you have a group of classes that have a set of behaviors that are the same, you can write tests that are applicable to the whole group...and then for each individual class you only need to write new tests for the unique behaviors (just copy the common ones). This method also helps keep consistency which can help improve quality in-and-of-itself.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.