How can I unit test the guard statement of a computed property in swift?
When the unit tests are run, the fataError
line is not included in the code coverage.
Is there any way to test the computed properties?
class HomePresenter: HomeViewToPresenterProtocol {
var view: HomePresenterToViewProtocol?
var router: HomePresenterToRouterProtocol?
var interactor: HomePresentorToInterectorProtocol?
var homeView: UIViewController {
guard let view = view as? UIViewController else {
fatalError("View cannot be casted as UIViewController")
}
return view
}
init(view: HomePresenterToViewProtocol, interactor: HomePresentorToInterectorProtocol, router: HomePresenterToRouterProtocol) {
self.view = view
self.interactor = interactor
self.router = router
}
}