在使用 `isolated` 进行 specs2 测试时,是否有必要使用 `class` 而不是 `object`?
Is it necessary to use `class` instead of `object` when using `isolated` for specs2 tests?
对于specs2测试,我们可以使用object
或class
来包含测试:
object MyTests extends Specification
class MyTests extends Specification
但是如果我想使用isolated
,我必须使用class
吗?
class MyTests extends Specification {
isolated
}
我问这个是因为我发现,当我使用object
时,测试有时会报错:
NoSuchElementException: : head of empty list (file:1)
但是当我改成class
时它就消失了
这确实是您使用的 specs2 版本的错误。这部分已在 specs2 3.x 中重新实现并且工作正常。
对于specs2测试,我们可以使用object
或class
来包含测试:
object MyTests extends Specification
class MyTests extends Specification
但是如果我想使用isolated
,我必须使用class
吗?
class MyTests extends Specification {
isolated
}
我问这个是因为我发现,当我使用object
时,测试有时会报错:
NoSuchElementException: : head of empty list (file:1)
但是当我改成class
这确实是您使用的 specs2 版本的错误。这部分已在 specs2 3.x 中重新实现并且工作正常。