Using Guard In Unit Tests

Dominik Hauser on using guard for unit tests:

“Here is the problem: Sometimes you want to test an element that could be nil. For example, I recently wanted to test if a view controller has a right bar button item with a given target.”

however…

“The problem with this code is, that if there is no right bar button item the test execution crashes. “

Using Guard In Unit Tests