Akka comes with a dedicated module akka-testkit for supporting tests at different levels.
Questions tagged [akka-testkit]
140 questions
2
votes
1 answer
gradle test for akka with testkit
I have a Scala + Akka + Gradle application and the following test:
class UserCRUDSpec() extends TestKit(ActorSystem("UserCRUDSpec"))
with ImplicitSender
with WordSpecLike
with Matchers
with Mockito
with DomainSuit {
val userDao: UserDao…

Alexander Davliatov
- 723
- 2
- 8
- 13
2
votes
1 answer
Updating data in a Finite state machine
I am using the FSM framework with AKKA using its Java API to manage state transitions . Here is the relevant portion of the state machine
when(QUEUED,
matchEvent(Exception.class, Service.class,
(exception, dservice)…

user_mda
- 18,148
- 27
- 82
- 145
2
votes
1 answer
TestKit unit test failure for AbstractPersistentActorWithAtLeastOnceDelivery actor created with TestActorRef
I am trying to write unit test for one of my actors which is derived from AbstractPersistentActorWithAtLeastOnceDelivery using TestKit. I need to create an actor with TestActorRef.create(...) since I need to get an underlyingActor in order to…

MrkK
- 873
- 3
- 12
- 22
2
votes
1 answer
Embedding multiple tests inside an akka-http route check
I'm using akka-http for the first time - my usual web framework of choice is http4s - and I'm having trouble getting the way I usually write endpoint unit tests to work with the route testing provided by akka-http-testkit.
Generally, I use ScalaTest…

Astrid
- 1,808
- 12
- 24
2
votes
1 answer
Route TestKit in asynchronous ScalaTest
I am switching synchronous ScalaTest tests of some Akka HTTP code to AsyncFunSpec. Is there a simple way to make Akka TestKit tests asynchronous, as well? I am talking about code like:
Get("/test") ~> testRoute ~> check {
responseAs[String]…

js.
- 1,787
- 19
- 22
2
votes
1 answer
Akka Http: how to test a route with a flow to 3rd party service?
I have a route in akka-http app which is integrated with a 3rd party service via Http().cachedHostConnectionPoolHttps. I want to test it in a right way. But not sure how it should be :(
Here is how this route looks like:
val routes: Route =…

Alex Fruzenshtein
- 2,846
- 6
- 32
- 53
2
votes
1 answer
Testing behavior not consistent when watching actor for termination
When I write tests that involve subscribing to events on the Eventstream or watching actors and listning for "Terminated", the tests work fine running them 1 by 1 but when I run the whole testsuite those tests fail.
Tests also works if each of those…

Lejdholt
- 532
- 7
- 21
2
votes
1 answer
How to make tests on akka actors response?
I am trying to understand the akka-Testkit", and hope it is ok to ask about it.
I found some tutorials and blogs that either access a state- or a lastMsg- attribute on the underlyingActor on the TestActorRef. However, a TestActorRef from the the…

stian
- 1,947
- 5
- 25
- 47
2
votes
0 answers
Proper TDD + Dependency Injection in Akka.net
I have and Agent, that will read directory X and create child agent for each subdirectory it finds.
To for my testing enviroment I've used System.IO.Abstractions package that creates IFileSystem interface and it's implementation (for normal program…

Marcin Konrad Ceglarek
- 1,442
- 2
- 13
- 20
2
votes
1 answer
Akka Actor isTerminated deprecated
Just writing a unit test to ensure an actor shuts down under certain conditions, so I have a test like:
val tddTestActor = TestActorRef[MyActor](Props(classOf[MyActor], "param1"))
tddTestActor ! someMessage
tddTestActor.isTerminated…

Exie
- 466
- 5
- 16
2
votes
1 answer
akka: test for a message modulo some fields
I am currently testing an akka application.
I have come across a certain pattern: I want to test that a TestProbe has received a certain message, modulo some fields.
For example, if the message was:
UserInfo(username: String, score: Int, timestamp:…

Mullefa
- 1,237
- 1
- 15
- 27
2
votes
3 answers
Does ActorRef obtained via system.actorOf equal to self inside this actor?
I've designed an actor that should send its' actorRef to another actor on prestart:
class MyActor(notifier: ActorRef) extends Actor {
override def preStart(): Unit = {
notifier ! Register(self)
}
...
}
case class Register(actor:…

Alexander Tokarev
- 2,743
- 2
- 20
- 21
2
votes
1 answer
Spray route testing with Akka TestProbe
In my Spray route, I delegate to an actor to process the request. The RequestContext is sent in the message to that actor.
path("mypath") {
parameters("thing".as[String]) { thing => ctx =>
myActor ! ProcessThingAndResondToContext(thing, ctx)
…

Synesso
- 37,610
- 35
- 136
- 207
1
vote
1 answer
Testing Akka Typed actors - How can I get an ActorContext?
I'm trying to unit test a helper function of my actor. This helper function spawns some actors and I want to assert that this happens. In order to spawn them, the helper function needs the parent ActorContext, so that is passed in. Example:
def…

JoeMjr2
- 3,804
- 4
- 34
- 62
1
vote
1 answer
Akka Typed testing - Expect message of type without knowing message details
Let's say I have an Actor (OrderGenerator) that in response to an incoming message (GenerateOrder), sends a message to another Actor (OrderProcessor) of type Order.
case class Order(orderId: String, partNumber: String, orderQty: Int) // ...etc.
In…

JoeMjr2
- 3,804
- 4
- 34
- 62