8

I am writing a specs2 Unittest for my scala software. The execution is working well. The only problem I have, is that I need to clean up after all test are finished. I just cannot find any solution for that. Is there a way to execute some functions after all test are finished?

tgr
  • 3,309
  • 2
  • 30
  • 57

2 Answers2

10

You need to add a Step at the end of your specification:

import org.specs2.mutable._

class MySpec extends Specification {

  // lots of examples here

  // cleanup there
  step(cleanUp())
}
Eric
  • 15,249
  • 36
  • 60
0

You can try to use After with After and implement def after function.

Example:

class Context extends Specification {
....
}

trait trees extends mutable.After {
  def after = cleanupDB
}
Robertiano
  • 352
  • 1
  • 6