如何迅速对计算属性的保护声明进行单元测试?
运行单元测试时,代码覆盖范围中不包含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
}
}