在单元测试中使用消息文件的方式是什么

时间:2018-06-12 07:42:06

标签: playframework-2.6

我创建了一个单元测试,但它没有使用播放应用程序的实例。我注意到没有应用程序,我的控制器没有使用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文件吗?

0 个答案:

没有答案