Swifty Waves

TODO: Explore PF testing lib

Testing Optionals

Following Sundell article on Avoiding force unwrapping in Swift unit tests, a cheat sheet can be:

Sticking with optionals

Use this for the common cases where a method/var is an optional

Throwing tests

If the method throws an error, we should use try to call it. It will crash if it returns nil. The main code will use try?.

Encapsulate method to throws error

If the method doesn't throws an error (and we don't want or can) add the throws, we can use an encapsulation method (through) an extension in order to replicate the same behaviour.

Tagged with: