我创建了一个单元测试,但它没有使用播放应用程序的实例。我注意到没有应用程序,我的控制器没有使用messages
文件,我必须通过创建DefaultMessagesApi
val messagesApi = new DefaultMessagesApi( //takes map of maps. the first is the language file, the 2nd is the map between message title and description
Map("en" -> //the language file
Map("error.incorrectBodyType" -> "Incorrect body type. Body type must be JSON") //map between message title and description
)
)
val controller = new UserController(mockUserRepository,mockControllerComponents,mockSilhouette,messagesApi,stubLangs())
我可以在单元测试中使用现有的messages
文件吗?