- As a testing framework, we will use ScalaTest
- ScalaTest offers different styles of testing. In the repo examples,
WordSpecLike
style is used.
For testing actors we can use akka-actor-testkit-typed. Extending ScalaTestWithActorTestKit
abstract class actor system for tests is created and all it's lifecycle is managed and cleaned up properly. We have two types of testing:
- Synchronous testing on one thread, explained here: https://doc.akka.io/docs/akka/current/typed/testing-sync.html#synchronous-behavior-testing
- Asynchronous testing - preffered as it more closely imitates real environment (uses real ActorSystem), explained here - https://doc.akka.io/docs/akka/current/typed/testing-async.html
All tests are in src/test/scala/myActorTest
. To run tests execute sbt test
.
The template for Lab 3: https://github.com/agh-reactive/reactive-scala-labs-templates/tree/lab-3
- be sure that your local lab-3 branch is up to date with remote one
- remember about merging solution from lab 2 into this branch
- (20 points)
-
Add new actors
OrderManager
andPayment
and create an actor system according to the diagram below: -
Add test for
CartActor
. Tests should contain:- synchronous testing
- asynchronous testing
- (10 points) Using actor testkit implement tests for
Checkout
actor to assess the behavior presented below (in particular check ifCart
actor receivesConfirmCheckoutClosed
message from its child -Checkout
)
- (10 points) Change implementation to use in
OrderManager
the Adapted Response pattern. Tip: actors (e.g.Checkout
) should send responses in the form of events (e.g.CheckoutClosed
), and the adapter should map them into commands (e.g.ConfirmCheckoutClosed
).
- More on the Message adapter pattern
Use the following steps to submit your solution.
First, before implementing the solution:
- Merge
lab2-solution -> master
- Merge
lab-3 -> master
(resolve conflicts)
Next:
- Create branch
lab3-solution
(frommaster
) - Implement the assignments using
lab3-solution
- Create a PR
lab3-solution -> master
- Submit the link to the PR as a solution