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

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 with 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 a limit to such things?

We can often find these silly questions crop up in software projects when your boss asks you how much time you need to complete a particular feature.

What would your answer be?

You can tell her that you need to analyze similar features previously developed in order to give a more accurate answer.

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

Then, she will 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 of ourselves or of others means that we’re looking for an answer that allows us to not commit on something. Or that makes other people commit.

When a 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, truthfully, we are looking for an answer that tells us we don’t need to – or that we only need 80% coverage.

There’s always a fight between dogmatic and pragmatic people. If you’re a dogmatic developer you probably follow 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 they are not necessary.

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

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