Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Testing Actors in Akka

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?

like image 713
lito Avatar asked Nov 14 '13 19:11

lito


People also ask

How do I test the Akka classic actor APIs?

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.

What are actors in Akka?

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

What is the difference between Akka testkit and actor model?

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.

How do I use Akka testkit?

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.


1 Answers

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 { 
like image 108
1esha Avatar answered Oct 13 '22 22:10

1esha