Automated tests are worthless if they don’t assert anything, but the problem of regular JUnit assertions is that they speak the wrong language and become messy if we have to write a lot of them. If we want to write tests which are both easy understand and maintain, we have to figure out a better […] Read more
Clean Code
Creating new objects is an essential part of automated testing, and the most obvious way to do it is to use the new keyword. However, this is not the best way to create new objects in our test cases, and using the new keyword will make our tests harder to read and maintain. This blog […] Read more
Magic is the arch enemy of readable code, and one of the most common form of magic which can be found from our code is a magic number. Magic numbers litters our source code, and transforms it into a pile of unreadable and unmaintainable rubbish. That is why we should avoid magic numbers at all […] Read more
When we are writing automated tests for our application, we have to name our test classes, our test methods, fields of our test classes, and the local variables found from our test methods. If we want to write tests which are easy to read, we have to stop coding on autopilot and pay attention to […] Read more
The first thing that we have to do when we start writing either unit or integration tests is to configure our test classes. If we want to write clean tests, we must configure our test classes in a clean and simple way. This seems obvious, right? Sadly, some developers choose to ignore this approach in […] Read more
When we write automated tests (either unit or integration tests) for our application, we should notice pretty soon that Many test cases use the same configuration which creates duplicate code. Building objects used in our tests creates duplicates code. Writing assertions creates duplicate code. The first thing that comes to mind is to eliminate the […] Read more