Implicit method that returns the Application instance for the current test.
Implicit method that returns the Application instance for the current test.
Creates new instance of Application with parameters set to their defaults.
Creates new instance of Application with parameters set to their defaults. Override this method if you
need a Application created with non-default parameter values.
Creates a new Application instance before executing each test, and
ensure it is cleaned up after the test completes.
Creates a new Application instance before executing each test, and
ensure it is cleaned up after the test completes. You can access the Application from
your tests via app.
the no-arg test function to run with a fixture
the Outcome of the test execution
Trait that provides a new
Applicationinstance for each test.This
TestSuiteMixintrait's overriddenwithFixturemethod creates a newApplicationbefore each test and ensures it is cleaned up after the test has completed. You can access theApplicationfrom your tests as methodapp(which is marked implicit).By default, this trait creates a new
Applicationfor each test using default parameter values, which is returned by thenewAppForTestmethod defined in this trait. If your tests need aApplicationwith non-default parameters, overridenewAppForTestto return it.Here's an example that demonstrates some of the services provided by this trait:
package org.scalatestplus.play.examples.oneapppertest import org.scalatest._ import org.scalatestplus.play._ import play.api.{Play, Application} import play.api.inject.guice._ class ExampleSpec extends PlaySpec with OneAppPerTest { // Override newAppForTest if you need an Application with other than non-default parameters. implicit override def newAppForTest(testData: TestData): Application = new GuiceApplicationBuilder().configure(Map("ehcacheplugin" -> "disabled")).build() "The OneAppPerTest trait" must { "provide an Application" in { app.configuration.getString("ehcacheplugin") mustBe Some("disabled") } "make the Application available implicitly" in { def getConfig(key: String)(implicit app: Application) = app.configuration.getString(key) getConfig("ehcacheplugin") mustBe Some("disabled") } "start the Application" in { Play.maybeApplication mustBe Some(app) } } }