2013-11-01 64 views
0

我使用播放2.2和Specs2并具有下列测试游戏框架:在运行播放测试

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正在访问下列方式中的应用

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 
} 
时IntegrationSpec忽略配置提供给FakeApplication

当运行play test时,使用的configParam.valueapplication.conf中的一个,而不是在FakeApplication中通过的那个。

我在这里做错了什么?

+0

更多细节将是不错的。您正在使用的Play和Specs2的版本等。另外还有您在此处使用的类的Imports。 –

+0

我已添加版本和导入语句 – Prasanna

回答

1

问题可能是Map传递给additionalConfiguration

你传递一个Int并试图获得一个字符串 “的getString”

尝试更改为这样:

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

通知的"2左右。