ScalaTest afterAll () is called after each test.

TL; DR; In the specification, ScalaTest, which mixes both in BeforeAndAfterAlland ParallelTestExecutionafter, is called after each test afterAll(), and then after all of them. I only need behavior.

I have a ScalaTest specification:

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")
      }
   }
}

Two tests want to separate the device, then afterAll()must clean the device. I omitted the details of the device code as not relevant to this issue.

Here is the output of my test:

foo
afterAll
bar
afterAll
afterAll

So, after each test is called afterAll(), and then after all of them. I want it to be called after all the tests.

Does anyone know why it afterAll()behaves this way?

Update

If I don't mix in ParallelTestExecution, my test behaves correctly:

foo
bar
afterAll

, ParallelTestExecution. ?

+4
2

, , concurrency, ParallelTestExecution Test. TestSpec, beforeAll afterAll .

( beforeAll afterAll ) , . question .

+3

All Articles