0

I want to know in what order the tests are running, because I want to run my initial test setup tests only once before all the tests start running.

If I have one initial setup test class, and one essential test class it would be fine:

   class EssentialTesting @Inject()(setupTests: SetupTest) extends ....{
    setupTests.runInitialSetup()
    .....
   } 

However if I have number of testings classes the setupTests.runInitialSetup will be repeated in each class. How to deal with this duplication?

o-0
  • 1,713
  • 14
  • 29

1 Answers1

0

Make your Setups class like:

 class SetUpTest extends SpecificationLike with BeforeAndAfterAll{
    override def beforeAll() = {
     // runs before each test
      }
    override val afterAll() = {
    // runs after each test
      }

}

Now in your test file, you can extend your SetUpTest, like :

class Test extends PlaySpecification with SetupTest

Now you don't need to call the runinitialsetup every time, just put it into beforeAll method and it will get executed before each test. And SpecificationLike is required as BeforeAndAfterAll has self type reference for SpecificationLike.

geek94
  • 443
  • 2
  • 11
  • Thanks for the answer. Hmm interesting... what is the library related to SpecificationLike? Also this approach is not what I want: I want to run my setup test only once, before running the essential tests. – o-0 Mar 27 '18 at 09:49
  • The library is -> specs2 – geek94 Mar 27 '18 at 09:53
  • I want to run my setup tests only once before all the tests. I dont want to run them before each individual test. – o-0 Mar 27 '18 at 10:31
  • for your scenario, you can do the above for anyone test case and make it run before every test case. To run test cases in order, you can have a look at this answer: https://stackoverflow.com/questions/14237420/how-to-order-execution-of-tests-in-sbt – geek94 Mar 27 '18 at 11:08