How to do unit testing in Swift
Why should we do unit testing with Swift? Unit testing is a crucial part of every SW project. It’s main purpose is to prevent errors from shipping. Unit tests also works as a safety net for you program. If you have written a big piece of code few months ago, and now you need to refactor that, unit tests are your best friend. Unit tests make sure you won’t break anything. If you have written test for all use cases and corner cases, you can be sure even after the refactoring that the application works as intended in the first place.
Unit tests also document the code. Usually it helps a lot to check the unit tests for a struct or class to what it is all about.
I’ll collect the best techniques and ideas about unit testing with swift under this category. Some of the posts are small and on a very specific topic mock network layer for unit testing with Swift. But others, for example how to unit test ViewModel in swift, are complete tutorials about a bigger topic.
I hope you’ll find the topics helpful, and if there is something you’ll like to add or ask about, please do!