QuickDevGuide

Home › Play Framework (Java)

Testing Play Applications — Play Framework (Java)

Play ships test helpers for every level: Level Tool Unit test a service plain JUnit, construct with fakes Controller in isolation call the action and inspect Result with Helpers.status / contentAsString Through the router Helpers.route(app, fakeRequest(GET, "/products")) with WithApplication Override bindings GuiceApplicationBuilder().overrides(bind(PriceService.class).to(FakePrices.class)) In-memory DB Helpers.inMemoryDatabase() (H2) Real HTTP server / browser WithServer, WithBrowser (FluentLenium/Selenium) Run with sbt test, or sbt "testOnly ProductControllerTest" for one class.

Key Takeaways