# How to use \`BehaviorTestKit\` for a typed actor which creates an \`ActorMaterializer\`?

**URL:** <https://discuss.akka.io/t/how-to-use-behaviortestkit-for-a-typed-actor-which-creates-an-actormaterializer/654>\
**Category:** Actors\
**Created:** [April 9, 2018, 3:40pm UTC](https://discuss.akka.io/t/how-to-use-behaviortestkit-for-a-typed-actor-which-creates-an-actormaterializer/654 "2018-04-09T15:40:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hseeberger](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.akka.io/hseeberger/32/2702_2.png) [@hseeberger](https://discuss.akka.io/u/hseeberger)\
**Post date:** [April 9, 2018, 3:40pm UTC](https://discuss.akka.io/t/how-to-use-behaviortestkit-for-a-typed-actor-which-creates-an-actormaterializer/654/1 "2018-04-09T15:40:33Z")

</div>

Example:

```auto
Behaviors.setup { context =>
  implicit val mat: Materializer = ActorMaterializer()(context.system)
  ???

```

Don’t say “not at all” ;-)

---

<div class="post-metadata">

**Author:** ![patriknw](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.akka.io/patriknw/32/89_2.png) [@patriknw](https://discuss.akka.io/u/patriknw)\
**Post date:** [April 9, 2018, 7:45pm UTC](https://discuss.akka.io/t/how-to-use-behaviortestkit-for-a-typed-actor-which-creates-an-actormaterializer/654/2 "2018-04-09T19:45:37Z")

</div>

I guess it fails already when creating the materializer (system.systemActorOf). We should probably have a clear error message for such things that are not supported by BehaviorTestKit.

It’s only a narrow set of tests that can be written with BehaviorTestKit. See them as unit tests of Behaviors. As with all unit tests some things must be stubbed instead of the real thing.

---

<div class="post-metadata">

**Author:** ![hseeberger](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.akka.io/hseeberger/32/2702_2.png) [@hseeberger](https://discuss.akka.io/u/hseeberger)\
**Post date:** [April 9, 2018, 8:08pm UTC](https://discuss.akka.io/t/how-to-use-behaviortestkit-for-a-typed-actor-which-creates-an-actormaterializer/654/3 "2018-04-09T20:08:16Z")

</div>

Yeah, but for stubbing/mocking these things need to be interfaces: for Materializer that works easily, but not for the extensions like CoordinatedShutdown, Http, etc. See my other questions, tickets …

---

<div class="post-metadata">

**Author:** ![patriknw](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.akka.io/patriknw/32/89_2.png) [@patriknw](https://discuss.akka.io/u/patriknw)\
**Post date:** [April 11, 2018, 8:30am UTC](https://discuss.akka.io/t/how-to-use-behaviortestkit-for-a-typed-actor-which-creates-an-actormaterializer/654/4 "2018-04-11T08:30:00Z")

</div>

I have started a PR to support extensions and stubbing/mocking of those in BehaviorTestKit: [https://github.com/akka/akka/pull/24878](https://github.com/akka/akka/pull/24878)
