Doing something before or after all Scalatest tests

后端 未结 3 1316
情歌与酒
情歌与酒 2020-11-29 01:32

I have a suite of scalatest tests that test different endpoints of a RESTful API. I really want them separated into different files for best organization.

My problem

3条回答
  •  失恋的感觉
    2020-11-29 02:00

    Alternatively you can just use an object.

    object TestServer {
      startServer()
    }
    

    When you access the object it will be initialised, starting the server. Just create a common trait in the body of which you access the object. Then mixin that trait into all your tests. Done.

    If your server runs in daemon mode (e.g. a Play! application in test mode) it will be automatically shut down after all tests are run.

提交回复
热议问题