ScalaTest:是否可以结合使用 AsyncWordSpec 和 GuiceOneAppPerSuite
ScalaTest: Is it possible to combine AsyncWordSpec and GuiceOneAppPerSuite
我想将我的验收测试从 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)
它适用于我的单元测试。
- 我需要调整我的测试吗?
- 或者不能混合使用?
使用的版本:
- 播放:2.6.15
- Scala 测试:3.0.5
- scalatestplus-play: 3.1.2
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 {
}
我在 Github 中找到了未解决的问题:
https://github.com/playframework/scalatestplus-play/issues/112
我想将我的验收测试从 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)
它适用于我的单元测试。
- 我需要调整我的测试吗?
- 或者不能混合使用?
使用的版本:
- 播放:2.6.15
- Scala 测试:3.0.5
- scalatestplus-play: 3.1.2
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 {
}
我在 Github 中找到了未解决的问题:
https://github.com/playframework/scalatestplus-play/issues/112