如何快速对计算属性的保护语句进行单元测试?
运行单元测试时,该fataError
行不包含在代码覆盖范围内。
有什么方法可以测试计算的属性吗?
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
}
}