How to write good tests

Forketyfork
3 min readFeb 4, 2022
Image by Nandhu Kumar from Pixabay

A secret to writing good tests is keeping in mind that there are only two reasons for a test to exist:

1. Making sure your code works as expected.

2. Avoiding regression bugs.

That’s it. There are no other reasons for a test to exist. Think of it whenever you face any of those questions:

  • should I try to achieve 100% code coverage?

--

--

Forketyfork

Software developer @ JetBrains Space. I write technical how-to articles and occasional rants on software development in general. Opinions are my own.