0
votes

I am working in Java Play Framework project. I want to write some JUnit test cases to test my application code.

Now for my JUnit cases, I need to initiate the play server Application to get all the configuration.

How do I get current play Application instance to initiate my Global ServerConfig in JUnits

Example type of code:

@Test
TestCode(){

Global.init(CurrentApplication_Instance);
//tes

}

Where CurrentApplication_Instance should be current running play.Play.application().

1

1 Answers

0
votes

You can extend your Test-Class from play.test.WithApplication which starts an application at the beginning of the test and provides it as a property. So you could:

public class MyTest extends play.test.WithApplication {
    @Test
    TestCode(){
        Global.init(app);
    }
}