Is it Akka best practice to restart actor systems for each test case? In beforeEach or afterEach?
From my search results on the internet, starting akka system is semi expensive because of setting up resources like threadpools.
I’ve been only stopping actor systems at the end of the test class in afterAll and was wondering if this is the recommended best practice.
With the out-of-the-box test integrations for Junit 4 (and for Scalatest in the Scala APIs) there is one actor system created per test class that is then shared among all test cases. Just like you say, because it is somewhat expensive to start up. For some tests scenarios it might be important to have an isolated actor system that will not be shared among test cases but better to opt-out of the shared system for those.
You can find docs for the Junit integration here: Asynchronous testing • Akka Documentation