TLDR; In a ScalaTest spec that mixes in both BeforeAndAfterAll and ParallelTestExecution, afterAll() is being called after each test, then again after all of them. I only want the after all behaviour.
I have a ScalaTest spec like this:
class TestSpec extends fixture.FunSpec with ShouldMatchers with BeforeAndAfter with BeforeAndAfterAll with ParallelTestExecution {
override def afterAll() = {
println("afterAll")
}
describe("something") {
it("should foo") {
println("foo")
}
it("should bar") {
println("bar")
}
}
}
The two tests want to share a fixture, then afterAll() should clean up the fixture. I've omitted the details of the fixture code as immaterial to this question.
Here's the output of my test:
foo
afterAll
bar
afterAll
afterAll
So afterAll() is being called after each test, then again after all of them. I only want it to be called after all tests.
Does anyone know why afterAll() is behaving like this?
Update
If I don't mix in ParallelTestExecution, my test behaves properly:
foo
bar
afterAll
Unfortunately, I actually want ParallelTestExecution. Is there any way to have my cake and eat it too?