Here is one thing you can do:
import org.specs2.mutable.SpecificationLike
import org.specs2.specification._
class TestSpec extends Actors { isolated
"test1" >> ok
"test2" >> ok
}
abstract class Actors extends
TestKit(ActorSystem("testsystem", ConfigFactory.parseString(TaskSpec.config)))
with SpecificationLike with AfterExample {
override def map(fs: =>Fragments) = super.map(fs) ^ step(system.shutdown, global = true)
def after = system.shutdown
}
This should avoid the compilation error you had because TestKit
is an abstract class and it is only mixing-in traits: SpecificationLike
is a trait (Specification
isn't) and AfterExample
is a trait.
Also the specification above runs in the isolated
mode, meaning that there is a brand new TestSpec
object instantiated for each example and the AfterExample
trait makes sure that the system is shutdown after each example.
Finally the map
method is overriden with a special step
to make sure that the system
created for the first TestSpec
instance (the one declaring all the examples) will be cleanly disposed of.