我想将验收测试从WordSpec
切换到AsyncWordSpec
。
现有特征如下:
import org.scalatest.WordSpec
import org.scalatestplus.play.guice.GuiceOneAppPerSuite
class PetDBSpec
extends WordSpec
with GuiceOneAppPerSuite {
}
如果我更改为AsyncWordSpec
,则必须这样更改:
import org.scalatest._
import org.scalatestplus.play.guice.GuiceOneAppPerSuite
class PetDBSpec
extends AsyncWordSpec
with GuiceOneAppPerSuite { this: TestSuite =>
}
但仍然会出现此异常:
[error] ... class PetDBSpec needs to be abstract, since method withFixture in trait TestSuiteMixin of type (test: PetDBSpec.this.NoArgTest)org.scalatest.Outcome is not defined
[error] (Note that TestSuiteMixin.this.NoArgTest does not match AsyncTestSuite.this.NoArgAsyncTest)
它与我的UnitTests一起正常工作。
使用的版本:
答案 0 :(得分:1)
GuiceOneAppPerSuite的声明如下:
trait GuiceOneAppPerSuite
extends BaseOneAppPerSuite
with GuiceFakeApplicationFactory { this: TestSuite =>
}
从上面的代码中,您可以看到GuiceOneAppPerSuite希望与TestSuite混合使用。
import org.scalatest._
import org.scalatestplus.play.guice.GuiceOneAppPerSuite
class PetDBSpec
extends AsyncWordSpec
with TestSuite
with GuiceOneAppPerSuite {
}
答案 1 :(得分:0)
我在Github中发现了未解决的问题:
https://github.com/playframework/scalatestplus-play/issues/112