有人可以帮忙吗。我有 Play2 项目,我需要在其中测试一些 DAO 代码。我使用了来自 http://www.playframework.org/documentation/2.0.2/ScalaTest的文档。测试非常简单:
import models.Calendar
import org.specs2.mutable._
import play.api.test._
import play.api.test.Helpers._
class CalendarSpec extends Specification {
"Calendar model" should {
"be retrieved by id" in {
val fakeApp = FakeApplication()
running(fakeApp) {
lazy val calendarId= Calendar.addCalendar(
Calendar(subject="test",
upAccount = "mytest",
masterId = 1,
calendarType = 1,
isAllDayEvent = false,
hasAttachment = false,
category = "test",
instanceType = 1,
upName = "test" ))
lazy val Some(calendar) = Calendar.getCalendar(calendarId.get)
calendar.upAccount must equalTo("mytest")
}
}
}
}
当我运行“sbt test”时,出现奇怪的错误:
[info] Calendar model should
[error] ! Fragment evaluation error
[error] ThrowableException: play.api.test.Helpers$.play$api$http$HeaderNames$_setter_$ACCESS_CONTROL_ALLOW_ORIGIN_$eq(Ljava/lang/String;)V (TraversableLike.scala:194)
[error] play.api.http.HeaderNames$class.$init$(StandardValues.scala:195)
[error] play.api.test.Helpers$.<init>(Helpers.scala:16)
[error] play.api.test.Helpers$.<clinit>(Helpers.scala:111)
[error] CalendarSpec$$anonfun$1$$anonfun$apply$1.apply(CalendarSpec.scala:13)
[error] CalendarSpec$$anonfun$1$$anonfun$apply$1.apply(CalendarSpec.scala:10)
[error] play.api.test.Helpers$.play$api$http$HeaderNames$_setter_$ACCESS_CONTROL_ALLOW_ORIGIN_$eq(Ljava/lang/String;)V
[error] play.api.http.HeaderNames$class.$init$(StandardValues.scala:195)
[error] play.api.test.Helpers$.<init>(Helpers.scala:16)
[error] play.api.test.Helpers$.<clinit>(Helpers.scala:111)
[error] CalendarSpec$$anonfun$1$$anonfun$apply$1.apply(CalendarSpec.scala:13)
[error] CalendarSpec$$anonfun$1$$anonfun$apply$1.apply(CalendarSpec.scala:10)
StackOverflow/Google 对此异常一无所知。提前致谢。