jjzjj

UserModelInterface

全部标签

testing - 如何在测试中将模型与 Controller 分开?

所以我想在测试中将Controller与模型隔离开来,这样我就可以在出现问题时轻松解决问题。之前,我只是用模拟数据访问端点,但很难排除故障,因为测试从路由器一直运行到数据存储。所以我想也许我会为每个Controller(和模型)创建两个版本(MockController与Controller),并根据模式变量的值使用一个。简而言之,这就是我计划实现它的方式。constmodestring="test"//UserModelInterfaceistheInterfaceforUserModeltypeUserModelInterfaceinterface{Get()}//UserCont