8

我正在为我的 scala 软件编写一个 specs2 Unittest。执行工作良好。我唯一的问题是,在所有测试完成后我需要清理。我只是找不到任何解决方案。有没有办法在所有测试完成后执行一些功能?

4

2 回答 2

10

您需要在规范末尾添加一个步骤:

import org.specs2.mutable._

class MySpec extends Specification {

  // lots of examples here

  // cleanup there
  step(cleanUp())
}
于 2012-11-26T21:06:11.937 回答
0

您可以尝试使用 Afterwith After并实现def after功能。

例子:

class Context extends Specification {
....
}

trait trees extends mutable.After {
  def after = cleanupDB
}
于 2012-11-26T15:58:39.187 回答