I have a REST API application with several submodules with unit tests, and I need to have actor system in some of them. Can I share one actor system for all submodules tests? What is the best practice for this case?
Asked
Active
Viewed 63 times
0
-
Does this answer your question? [Multiple actor systems for an application](https://stackoverflow.com/questions/41254821/multiple-actor-systems-for-an-application) – Shankar Shastri Jun 10 '20 at 13:49
-
The best practice is not share actor systems and use `class XXXSpec extends TestKit(ActorSystem("test")) with ???` provided by akka-testkit – Ivan Stanislavciuc Jun 10 '20 at 18:08
-
what about variants like this? - https://github.com/1178615156/android-game-aux/blob/6d82c1b9bd228c0dcd33ba2bf47a186aca1dbd54/src/test/scala/sources/ImageTestSources.scala – Остап Страшевский Jun 10 '20 at 18:26
-
1This is basically what TestKit does for you. If you put ActorSystem initialisation into a trait, the code is shared but the instances are not shared. It will create a new actor system for each instance of class that extends this trait – Ivan Stanislavciuc Jun 11 '20 at 07:18
-
With TestKit you have the option of passing the same actor system via constructor. Thus it actually allows for sharing actor system. The trait you added does not – Ivan Stanislavciuc Jun 11 '20 at 07:21