Questions tagged [akka-testkit]

Akka comes with a dedicated module akka-testkit for supporting tests at different levels.

140 questions
1
vote
1 answer

Time for create TestProbe in Akka TestKit

I have trait for override actorOf in tests: trait ActorRefFactory { this: Actor => def actorOf(props: Props) = context.actorOf(props) } And I have worker actor, which stop self when receive any message: class WorkerActor extends Actor { …
Leonard
  • 551
  • 1
  • 10
  • 21
0
votes
0 answers

Need help testing a RestartFlow using Akka Stream Testkit

I have a following flow using Akka Stream scaladsl: @testOnly def restartableFlow: Flow[MyEvent, AmqpSendResult, NotUsed] = RestartFlow .withBackoff(restartSettings) { () => Flow[MyEvent] .mapAsyncUnordered(3)(acceptMessages)…
vasigorc
  • 882
  • 11
  • 22
0
votes
2 answers

Akka TestKit (Java), I want to only consume/expect message object which has some specific string?

I have an Actor, which publish different kind of messages at different events and junit has been written for that using TestKit. I want to consume message with "specific word" only and skip the rest. Below code consumes all the message but I want to…
Surendra
  • 119
  • 1
  • 1
  • 10
0
votes
1 answer

Akka Typed ActorTestKit - How to send Terminated signal

I have an existing unit test that uses BehaviorTestKit to test the actor's behavior when it receives a Terminated signal. I am able to send a Terminated signal to it like this: val myParentTestKit =…
JoeMjr2
  • 3,804
  • 4
  • 34
  • 62
0
votes
1 answer

Testing stop behavior of an EventSourcedBehavior in akka

I have an EventSourcedBehavior that will eventually get a message which leads to one last event and then stops itself. Implementing this is not the problem, but when I want to test it I get a DeadLetter Message because the…
null
  • 45
  • 1
  • 5
0
votes
1 answer

Akka Typed - How to sent Terminated message to BehaviorTestKit

I'm trying to unit test my actor's handling of a "Terminated" message for a child actor. The code under test is something like this: case Terminated(terminatedActor) => val actorName = terminatedActor.path.name if…
JoeMjr2
  • 3,804
  • 4
  • 34
  • 62
0
votes
1 answer

Akka BehaviorTestKit - Check for anonymous actor spawned of specific type, ignoring order

I'm trying to uss the Akka BehaviorTestKit to verify that an anonymous actor of a specific type is spawned. I tried to use: testKit.expectEffectType[SpawnedAnonymous[MyActor.Request]] When I did this, I got an AssertionError because there were…
JoeMjr2
  • 3,804
  • 4
  • 34
  • 62
0
votes
1 answer

C# Akka.Net Unit Tests which built-In Assertion is the correct to wait for a published message?

I need some support in order to uderstand how I could successfully wait for an expected response message that is sent from within an actor Receive block. The following example is different to what I could find so far in the web, because I use the…
chris
  • 3
  • 2
0
votes
1 answer

expectMsgAnyOf and expectMsgAllOf in Akka testkit typed

I have akka testkit (classic) and methods expectMsgAnyOf and expectMsgAllOf in TestKit class, which let me check several messages: "reply to a greeting" in { labTestActor ! "greeting" expectMsgAnyOf("hi", "hello") } "reply with…
Vadim
  • 753
  • 8
  • 22
0
votes
1 answer

Akka testkit with typed not compiling

I'm attempting to setup a simple Akka test using Testkit using following code : import akka.actor.typed.ActorRef; import akka.actor.typed.Behavior; import akka.actor.typed.Scheduler; import akka.actor.typed.javadsl.AskPattern; import…
blue-sky
  • 51,962
  • 152
  • 427
  • 752
0
votes
0 answers

Akka projection Test always fail

I should have missed something. But I am trying to test that my projection is sending a message to another Actor. My test is really simple and has one assertion: projectionTestKit.run(projection) { val message =…
gervais.b
  • 2,294
  • 2
  • 22
  • 46
0
votes
1 answer

How to disable Akka Dead Letters warnings in Tests

I recently upgraded to Akka 2.6.10. Now I'm seeing a lot of warnings like this when I run tests for my actors with ActorTestKit: [WARN] [12/16/2020 09:03:14.995] [AsyncTestWithControlledTime-akka.actor.internal-dispatcher-3]…
lex82
  • 11,173
  • 2
  • 44
  • 69
0
votes
1 answer

How can I test that an akka-streams sink was called?

I have a use case where I pass a sink to some actor - so I can also pass a TestSink When that actor receives a message I pass a message to that sink using case class SomeActor[T, U](sink: Sink[U, NotUsed] { def behavior: Behavior[T] =…
mrt181
  • 5,080
  • 8
  • 66
  • 86
0
votes
2 answers

Test Message Adapters in Akka Typed

I am using Akka Typed (version 2.6.8) and I developed an actor that uses a message adapter. object EncoderClient { sealed trait Command final case class KeepASecret(secret: String) extends Command private final case class…
riccardo.cardin
  • 7,971
  • 5
  • 57
  • 106
0
votes
1 answer

Akka test case assertion failure

I am trying to write test for an actor which sends: sender() ! Status.Failure(message) I have written the test case as: class TestActorSpec extends TestKit(ActorSystem("system")) with ImplicitSender with WordSpecLike with Matchers…
ARYA
  • 223
  • 1
  • 5
  • 15