How to run a game application in an integration test?

Say I have a play application

class AppLoader extends ApplicationLoader {
   override def load(context: Context): Application =
    new BuiltInComponentsFromContext(context) with AhcWSComponents { }.application
}

And I'm trying to run it in an integration test with some layouts for testing. My current (doesn't work) approach:

    lazy val app: Application = {
      val customContext = ApplicationLoader.createContext(Environment.simple(new java.io.File("."), Mode.Test))
      new AppLoader().load(customContext)
    }
    Play.start(app)

But the http server is not running, all my requests are denied using java.net.ConnectException: Connection refused (Connection refused).

Is there a way to run the application without magic?

+4
source share

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


All Articles