Test assertions in Swift
This week, let’s take a look at various ways that we can assert that our code produces the right outcomes within our unit tests, including how we can create our own assertion functions.
Articles, podcasts and news about Swift development, by John Sundell.
This week, let’s take a look at various ways that we can assert that our code produces the right outcomes within our unit tests, including how we can create our own assertion functions.
Assertions are not only an essential tool when writing tests - they're also super useful in order to write more predictable and easier to debug code. This week, let's look deeper into assertions, how they work, and how we can implement our own assert functions for performing various checks.
One major focus of Swift is compile time safety — enabling us as developers to easily focus on writing code that is more predictable and less prone to runtime errors. However, sometimes things do fail for various reasons — so this week, let’s take a look at how we can handle such failures appropriately, and what tools we have at our disposal for doing so.