Unit tests are a great way to have a clear and reliable code base. Good unit tests gives you the […]
Learn your testing framework
Testing frameworks can offer a lot in terms of features, assertions and utility functions. It is always better to learn […]
Test edge cases
Edge cases can be defined as a subset of tests that check extreme limits of valid input values. Testing edge […]
Avoid magic values
Like in production code, the way you are using and naming variables in unit tests is important. A magic value […]
Cover the maximum you can
Coverage is the measurement of how much production code is covered by unit tests. The most common types of code […]
Validate private methods using public methods
While is it possible to test private methods individually, it is good a practice to “cover” them by testing only […]
Avoid logic in unit tests
When you write unit tests, you should avoid logical structures such as conditions and loops. Adding unnecessary logic to your […]
Write fast unit tests
As mentioned before, fastness is one of the characteristics of a good unit test. Try to make your unit tests […]
Write isolated unit tests
Unit tests should run in complete isolation. When you write a unit test make sure it does not depend on […]
Test one thing at a time
The Idea behind unit testing is to verify that each “separate” unit of your software is working as expected. Tests […]