使用夹具将特征混合到ScalaTest中的测试方法中

时间:2018-07-27 01:23:52

标签: scala scalatest scalikejdbc

使用ScalaTest的{​​{1}}时,我可以创建一个夹具并将其混合到测试中,如下所示:

org.scalatest.FlatSpecLike

但是,当我改用class Foo extends FlatSpecLike with Matchers { trait Fixture { val bar = 2 } "This test method" should "not cause a compile error" in new Fixture { 2 shouldEqual bar } } 时,我不能这样做:

org.scalatest.fixture.FlatSpecLike

有人可以建议我如何使用class Baz extends fixture.FlatSpecLike with Matchers { trait Fixture { val bar = 2 } "This test method" should "cause a compile error" in new Fixture { implicit session => ... } } 将特征混入测试方法吗?

更新:

fixture.FlatSpecLike中运行~test:compile之后,这是编译器的错误:

SBT

Intellij显示类似in new Fixture { implicit session => [error] ^ [error] one error found [error] (Test / compileIncremental) Compilation failed

0 个答案:

没有答案