Prasanna
Prasanna

Reputation: 3771

Play Framework: IntegrationSpec ignoring configuration provided to FakeApplication when running play test

I am using Play 2.2 and Specs2 and having the following test

  import org.specs2.mutable.Specification
  import org.specs2.runner.JUnitRunner

  import play.api.test.Helpers.running
  import play.api.test.{FakeApplication, TestBrowser, TestServer}
  import java.util.concurrent.TimeUnit
  import org.openqa.selenium.firefox.FirefoxDriver
  import org.fluentlenium.core.domain.{FluentList, FluentWebElement}
  import org.openqa.selenium.NoSuchElementException

  "Application" should {
    "work from within a browser" in {
      running(TestServer(port, application = FakeApplication(additionalConfiguration = Map("configParam.value" -> 2)), classOf[FirefoxDriver]) {
      .....
      }
    }
  }

configParam.value is being accessed the following way in the application

import scala.concurrent.Future
import play.api.libs.json._
import play.api.Play._
import play.api.libs.ws.Response
import play.api.libs.json.JsObject

object Configuration {
   val configParamValue = current.configuration.getString("configParam.value").get
}

When running play test the configParam.value being used is the one from application.conf instead of the one passed in FakeApplication.

What am I doing wrong here?

Upvotes: 0

Views: 553

Answers (1)

alcarv
alcarv

Reputation: 899

The problem is probably with the Map passed to additionalConfiguration.

You're passing an Int and trying to get a String with "getString"

Try changing to this:

running(TestServer(port, application = FakeApplication(additionalConfiguration = Map("configParam.value" -> "2")), classOf[FirefoxDriver]) {

Notice the " around the 2.

Upvotes: 1

Related Questions