Question: How to start play application inside integration test?

Question

How to start play application inside integration test?

Answers 0
Added at 2016-12-27 08:12
Tags
Question

Let's say I have 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 inside integration test with some mocks to test. My current (not working) 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 http server isn't started, all my requests are rejected with java.net.ConnectException: Connection refused (Connection refused).

Is there any way to start play application without guice magic?

Answers to

How to start play application inside integration test?

Source Show
◀ Wstecz