Refactoring is a key factor to get high code quality. Too often we end up in a situation when refactoring is already too difficult. By refactoring constantly we can avoid that trap and keep our code clean.
Anyone who has written unit tests have been fighting with object creations. Some times it is so difficult to create objects used in tests. Test data builders come to rescue! With them I write better tests with less time.
Readability is key point in unit tests. One common antipattern with unit tests are setup methods, because they make unit tests more difficult to read. Here I have written how helper methods can be used instead of setup methods to make unit tests more readable.
Unit tests are my passion. I always write them and I also encourage others to write them and even have taught developers to write unit tests. But I am quite surprised how often developers don't write unit tests. There is a lot of benefits for writing unit tests. In this blog post, I will explain three main reasons why every developer should always write unit tests.