Should I test all setters and getters? What about testing code that I don’t own? Should I use pure TDD without skipping any step?

The short answer is: Yes.

But the long answer is: Yes, you should.

We shouldn’t set any limit to quality, we should always strive to get perfect each line of code and build 100% bug-free software solutions.


You may feel uncomfortable about these answers.

You’re right, it’s almost impossible to achieve these things.

But, what if I ask you how much money you would like to have. Or how much happiness or love you want in your life.

Is there such a limit?

We find this kind of silly questions in software projects when your boss asks you how much time you need to complete some feature.

What would your answer be?

You can tell her that you need to analyze similarly features previously developed in order to give an accurate answer.

However, the answer should be: “I need all the time in the world”.

Then, she would probably tell you: “I’ll give you 3 months”.

So, should you then test getters and setters?

You must test them. But, you may also choose not to.

The fact that we ask these questions to ourselves or some other person means that we’re looking for some answer that makes us not commit on something. Or that makes other people commit.

When your boss asks us how much time we need to finish something, he or she is trying to make us commit to the project schedule.

When we ask on the internet if we should have 100% coverage, we are looking for an answer saying we don’t need to – or that we only need 80%.

There’s always a fight between dogmatic and pragmatic people. If you’re a dogmatic developer you probably follows a TDD process without skipping any steps.

If you are a pragmatic developer you probably have your own version of TDD in which you simply skip some steps because you think it’s not necessary.

Both approaches are okay. You can use TDD with skipping steps. Or you can have only 80% test coverage. As long as you keep in mind we should not set any limit in quality just because that means more work for you.

I believe limits in quality should only be set by situations we can’t control.