Play2 does not allow messages when starting from unit test

I am trying to run unit tests for a Play 2 based application, and we are having a message problem. Apparently, this seam is not correctly initialized or is not initialized at all.

@Test public void testMessage() throws IOException { running(fakeApplication(), new Runnable() { @Override public void run() { Locale.setDefault(new Locale("en")); String test = Messages.get("test.test"); System.out.println("DUMMY --" + test); } }); } 

The output of the above code is "DUMMY - test.test", although I am expecting a permitted message.

Is there a problem with the message? Do I need to download the plugin / posts myself?

Thanks for the help in advance.

+4
source share
1 answer

I'm not sure if this will help in your case, but for my code base I needed to explicitly add the conf directory to my class path so that the tests could access resources from that directory. In my Build.scala file, I have:

 .settings( unmanagedClasspath in Compile <+= baseDirectory map { bd => Attributed.blank(bd / "conf") } ) 
0
source

Source: https://habr.com/ru/post/1494309/


All Articles