Clean Code

Writing Clean Tests - New Considered Harmful

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

Writing Clean Tests - Beware of Magic

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

Writing Clean Tests - Naming Matters

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

Writing Clean Tests - It Starts From the Configuration

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

Three Reasons Why We Should Not Use Inheritance In Our Tests

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