lam*_*das 21 testing scala scalatest
如何禁用测试套件,即类扩展中的所有测试FunSpec?
我已经发现的唯一的解决办法是更换it与ignore每次试验前,但它是无聊与几十个测试这样做.
Bil*_*ers 32
在1.8中执行此操作的简单方法是添加一个带有伪参数的构造函数.如果没有public,no-arg构造函数,ScalaTest(和sbt)将不会发现该类:
class MySuite(ignore: String) extends FunSuite {
// ...
}
Run Code Online (Sandbox Code Playgroud)
在2.0中,您将能够在课堂上编写@Ignore:
@Ignore
class MySuite extends FunSuite {
// ...
}
Run Code Online (Sandbox Code Playgroud)
根据scalatest文档,假设您是否有这样的测试套件
describe ("some component") {
it ("should do something") {
...
}
it ("should also do something else") {
...
}
}
Run Code Online (Sandbox Code Playgroud)
要仅禁用单个测试,您可以使用该ignore()方法。
describe ("some component") {
ignore ("should do something") {
...
}
...
}
Run Code Online (Sandbox Code Playgroud)
使用@DoNotDiscover
来自scaladoc:
import org.scalatest._
@DoNotDiscover
class SetSpec extends FlatSpec {
"An empty Set" should "have size 0" in {
assert(Set.empty.size === 0)
}
it should "produce NoSuchElementException when head is invoked" in {
intercept[NoSuchElementException] {
Set.empty.head
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14687 次 |
| 最近记录: |