Example Play Project using compile time dependency injection and Play WS with ScalaTest
Scala HTML Shell JavaScript
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.



This is an example of Play using the Scala API with manually wired compile time dependency injection.

The application loader here is MyApplicationLoader which uses MyComponents to wire together an injector.

For testing, a MyApplicationFactory is defined and mixed in:

trait MyApplicationFactory extends FakeApplicationFactory {

  override def fakeApplication: Application = {
    val env = Environment.simple(new File("."))
    val configuration = Configuration.load(env)
    val context = ApplicationLoader.Context(
      environment = env,
      sourceMapper = None,
      webCommands = new DefaultWebCommands(),
      initialConfiguration = configuration,
      lifecycle = new DefaultApplicationLifecycle()
    val loader = new MyApplicationLoader()


Once the MyApplicationFactory is defined, the fake application is used by TestSuite types:

class ServerSpec extends PlaySpec
  with BaseOneServerPerSuite
  with MyApplicationFactory
  with ScalaFutures
  with IntegrationPatience {

  private implicit val implicitPort = port

  "Server query should" should {
    "work" in {
      whenReady(play.api.test.WsTestClient.wsUrl("/").get) { response =>
        response.status mustBe play.api.http.Status.OK

Further Documentation