Version Matrix

Build status Maven

Fake Play WS Standalone

Fake Play WS Standalone is a mock library implementing Play WS Standalone interface. It can be used for testing of your HTTP clients without starting a web service.


To get started, add the following dependency into your project:

libraryDependencies += "" %% "play-fake-ws-standalone" % "LATEST_VERSION"

Replace LATEST_VERSION with the actual release version from the releases page.

And then you can start using the library:

import org.scalatest._

import scala.concurrent.duration.Duration
import scala.concurrent._
import scala.language.reflectiveCalls

  * Tests MyApi HTTP client implementation
class MyApiClientSpec extends AsyncFlatSpec with BeforeAndAfterAll with Matchers {
  implicit val system = ActorSystem()
  implicit val materializer = ActorMaterializer()
  import system.dispatcher

  behavior of "MyApiClient"

  it should "put access token to Authorization header" in {
    val accessToken = "fake_access_token"
    val ws = StandaloneFakeWSClient {
      case request @ GET(url"http://host/v1/foo/$id") =>
        // verify access token
        request.headers should contain ("Authorization" -> Seq(s"Bearer $accessToken"))
        // this is here just to demonstrate how you can use URL extractor
        id shouldBe "1"

    val api = new MyApiClient(ws, baseUrl = "http://host/", accessToken = accessToken)
    api.getFoo(1).map(_ => succeed)

  // ... more tests

  override def afterAll(): Unit = {
    Await.result(system.terminate(), Duration.Inf)



This project supports the following versions of play-ws

Fake WS version Play-WS version
1.0.x 1.0.x
1.1.x 1.1.x
2.0.x 2.0.x