0
votes

i need some help here.. im using specs2 so run my integration tests. so before everything is running, im setting up my simplicators (fake server my system interact with)

the problem is, that i need to find a way how to know when to shut down these servers once all tests are done. After and step() are not good enough as they happen in each individual test scope. i need something to run after ALL tests are done.

any ideas? thanks in advance!

1

1 Answers

1
votes

found it! here is how it is done!

if you struggle with it too - here is a nice interface to setup an IT Env:

trait FakeServer {
  def setup: Unit
  def tearDown: Unit
}

object ITEnvironment extends FakeServer{
  private val simplicators: Seq[FakeServer] = Seq(new FakeWebServer)

  override def setup: Unit = simplicators foreach { server => server.setup}
  override def tearDown: Unit = simplicators foreach { server => server.tearDown}
}

trait Specs2ITEnvironment { this: Specification =>
  sequential
  override def map(fs: =>Fragments) = Step( {ITEnvironment.setup} ) ^ fs ^ Step( {ITEnvironment.tearDown} )
}

class LoginIT extends SpecificationWithJUnit with Specs2ITEnvironment{
    ... your test here ...
}