jeudi 15 septembre 2016

scalatest beforeall() being called multiple times when running tests sequantially

I have a scala test Suite with 3 unit test cases, something like

    class MyTestSuite extends FlatSpec with Matchers with MockFactory with BeforeAndAfterEach with BeforeAndAfterAll
    {
       ...

I have beforeAll(), afterAll(), beforeEach() and afterEach() methods defined in my test suite.

According to this post, scala test suites runs test cases sequentially by default, I also believe it's actually running the test cases sequentially because in each of my tests I have a sleep statement for 20 seconds, and my entire test suite takes a little more than 60 seconds (3 * 20) to finish.

On the other hand, I have a println statement in my beforeAll() and it's actually printing 6 times. Could someone help to explain why beforeAll() is executed 6 times for a test suite with only 3 unit test cases? How can I force beforeAll() and afterAll() to only be executed once?

I'm using scala version 2.10.6 and scalatest 2.2.6 with IntelliJ 2016.2.2.

Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire