在阅读了有关此问题的几篇文章和文章后,我仍然对如何在 VIPER 架构中测试方法(例如使用 Swift)感到困惑。
如果我有这个代码:
演示者类
protocol InteractorToPresenterProtocol: class {
func showInfo(info: Info)
}
class Presenter {
private var interactor: PresenterToInteractorProtocol?
init() {}
func makeSomeStuffInPresenter() {
// make some stuff
...
interactor?.makeSomeStuffInInteractor()
}
}
extension Presenter : InteractorToPresenterProtocol {
func showInfo(info: Info) {
print(info)
}
}
交互类:
protocol PresenterToInteractorProtocol: class {
func makeSomeStuffInInteractor()
}
class Interactor {
private var presenter: InteractorToPresenterProtocol?
init() {}
}
extension Interactor : PresenterToInteractorProtocol {
func makeSomeStuffInInteractor() {
// make some stuff
...
presenter?.showInfo(info)
}
}
我应该如何测试 makeSomeStuffInPresenter 方法?