When i run base example for testing actors:
class MySpec(_system: ActorSystem) extends TestKit(_system) with ImplicitSender with WordSpec with MustMatchers with BeforeAndAfterAll {
I got error:
class WordSpec needs to be a trait to be mixed in
what am I doing wrong?
You are viewing the documentation for the new actor APIs, to view the Akka Classic documentation, see Classic Testing. Testing can either be done asynchronously using a real ActorSystem or synchronously on the testing thread using the BehaviorTestKit.
Actors are the basic building block of Akka, which represents small processing units with small memory footprints that can only communicate by exchanging messages. In this tutorial, we’ll look at how we can test Actors to ensure that they behave as expected. 2. Test Configuration
The actor model presents a different view on how units of code are delimited and how they interact, which influences how to perform tests. Akka comes with a dedicated module akka-testkit for supporting tests. Testkit allows you to test your actors in a controlled but realistic environment.
To use Akka Testkit, you must add the following dependency in your project: As with any piece of software, automated tests are a very important part of the development cycle. The actor model presents a different view on how units of code are delimited and how they interact, which influences how to perform tests.
In ScalaTest 2.0 you can find both class and trait for WordSpec
. The class named WordSpec
and trait is WordSpecLike
. So just use WordSpecLike
instead of WordSpec
:
class MySpec(_system: ActorSystem) extends TestKit(_system) with ImplicitSender with WordSpecLike with MustMatchers with BeforeAndAfterAll {
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With