【发布时间】:2015-03-12 12:11:23
【问题描述】:
如何正确使用 Scala Specs2 Notifier?
尚未找到任何示例来演示 Notifier 特征的一些用例。
编辑:
当按如下方式使用通知程序时,它可以完美运行:
class TestSpec extends TestUtils {
"Arithmetic" should {
"add two numbers" in {
1 + 1 mustEqual 2
}
"add three numbers" in {
1 + 1 + 1 mustEqual 3
}
}
}
class TestNotifier extends ConsoleNotifier
trait TestUtils extends Specification {
args.report(notifier = "com.stuff.TestNotifier")
}
但是,当我尝试为每个测试添加一些新的上下文创建时:
class TestSpec extends TestUtils {
trait Context {
val justNum = 4
}
"Arithmetic" should {
"add two numbers" in new Context {
1 + 1 mustEqual 2
}
"add three numbers" in new Context {
1 + 1 + 1 mustEqual 3
}
}
}
出现错误:
错误:(12, 23) 找不到证据参数的隐含值 类型 org.specs2.execute.AsResult[TestSpec.this.Context] 在新上下文中“添加两个数字”{
【问题讨论】:
-
这与通知程序无关。您收到此消息是因为
Context需要扩展org.specs2.specification.Scope才能用作示例正文。 -
目前我还没有使用规范参数来确定如何运行它。所以通知器参数必须在命令行上传递。
-
感谢 Eric,现在可以使用了。下次会记得的。