Here is what 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 a compilation error, because TestKit is an abstract class, and these are just signs of confusion: SpecificationLike is a sign ( Specification is not) and AfterExample is a sign.
Also, the above specification works in isolated mode, which means that a new TestSpec object is created for each example, and the AfterExample ensures that the system will be disconnected after each example.
Finally, the map method is overridden by a special step to make sure that the system created for the first TestSpec instance (the one that declares all the examples) will be cleared.
source share