无法在测试期间实例化controllers.WebJarAssets

时间:2015-11-24 15:09:01

标签: scala playframework-2.0 sbt specs2

当我使用sbt run时,播放工作正常。但是,当我尝试进行此类测试时:

@RunWith(classOf[JUnitRunner])
class MarketApiSpec extends Specification {
  "Market API" should {
    "load product list" in new WithApplication {
      val completed = route(FakeRequest("GET", "/api/products")).get.map(x => Json.parse(x.body.toString()))
      val jsonObject = Await.result(completed, Duration("1s"))
      jsonObject.get("products").get(0).get("name").asText() must beEqualTo("Programmer");
    }
  }
}

通过sbt test我得到了这样的错误异常:

[info] Market API should
[info] ! load product list
[error]    RuntimeException: : java.lang.NoClassDefFoundError: Could not initialize class controllers.WebJarAssets$  (Action.scala:523)
[error] play.api.mvc.ActionBuilder$$anon$1.apply(Action.scala:523)

我google了很多,但是我找不到解决方案。我认为它与sbt有某种关系,但即使给出一个测试范围也无济于事。

0 个答案:

没有答案