0

I am trying to test a TypedActor with akka-http and have issues while trying to create a Test case. For testing a TypedActor, I would write the following Spec...

class MyServiceTestSpec extends ScalaTestWithActorTestKit with FlatSpecLike with Matchers

But, when I would have to write a TypedActor used with HTTP /+ WS route, I am unable to write...

class MyHTTPServiceTestSpec extends ScalaTestWithActorTestKit with FlatSpecLike with Matchers with ScalatestRouteTest

This is because system member for ScalaTestWithActorTestKit is a typed.ActorSystem, while for ScalatestRouteTest is ActorSystem (untyped).

How would I be able to write a test that can use both?

Please advice.

Developer
  • 691
  • 8
  • 7

1 Answers1

2

There's currently no way to do that out of the box, you will have to introduce some glue like the ScalaTestWithActorTestKit and ActorTestKitBase in your own test sources for now. There's an issue tracking improving on the situation here: https://github.com/akka/akka-http/issues/2036

johanandren
  • 11,249
  • 1
  • 25
  • 30
  • I added `trait ScalatestTypedActorHttpRoute extends ScalatestRouteTest`. But, have to do some bad code of `var` for adapting the `ActorTestKit`'s system to untyped world of `ScalatestRouteTest.createActorSystem()`. Let me add my code snippet on the above issue. – Developer Aug 17 '19 at 15:48