akka / akka/akka-http

DOCS: show how to mock server responses in HTTP client tests

Open
#229 5 comments 1 reaction 0 assignees View on GitHub
1 - triaged
Dominant language
Scala
Stars
1.4k
Forks
584
Avg merge
14h 33m
Merged PRs (30d)
24

Description

**Issue by [rkuhn](https://github.com/rkuhn)**
_Friday Jul 17, 2015 at 07:16 GMT_
_Originally opened as https://github.com/akka/akka/issues/18022_

---

from the [mailing list](https://groups.google.com/d/topic/akka-user/-rsD467ADC4/discussion):

> I have an actor that is sending outbound http request.
> I would like top test that actor ,is there an option to mock that call ? what is the correct way for doing that ?

My answer in that thread:

> in order to switch out the actual HTTP part you’ll have to configure your Actor with this part, e.g. by providing a function “HttpRequest => Future[HttpResponse]” or a “Flow[HttpRequest, HttpResponse, _]” or similar. Then in your production code you plug in the HTTP client pool and in your tests you can simply stub it out by a function that provides canned answers.

Contributor guide

Open the contributing guide

Research direction

Read the linked mailing-list discussion and locate the HTTP client testing documentation around actors, the HTTP client pool, and injectable request/response behavior. Done means the documentation answers how to replace outbound HTTP calls with canned responses when testing an actor.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
documentation, testing
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.