Photo by Kai Pilger on Unsplash
4 π¦π’π¬πππ€ππ¬ you are doing while Unit testing that you need to ππππ right away:
"Unit testing is an essential part of the software development process, and it can help ensure that your code is correct, reliable, and maintainable.β
Avoid using the anti-patterns mentioned below:
πΌπππ πππππππ πππππππ ππππππ π:
Making private methods public just to enable unit testing is a big NO NO, because it couples tests to implementation and, ultimately, makes the tests fragile.
π¬πππππππ πππππππ πππππ ππ ππππππ ππππ πππππππ:
Donβt expose state that you would otherwise keep private for the sole purpose of unit testing. Your tests should interact with the system under test exactly the same way as the production code; they shouldnβt have any special privileges.
πΆππππππππ ππππππππ:
If you stub everything, you are testing a really small and simple and specific implementation detail. This will make your test fail almost instantly with a refactoring of a name or change in a serialisation method... Your tests will become unclear, brittle and less effective.
π³ππππππ π πππππ πππππππ ππ ππ πππππ:
Donβt imply any specific implementation when writing tests. Verify the code from a black-box perspective