Code Monkey home page Code Monkey logo

play-mockws's Introduction

play-mockws

Play MockWS is a mock WS client for Play Framework.

If:

  • you write an application in Scala with the Play Framework
  • the application makes HTTP calls to external web services with the WS client
  • you want to test your implementation

then you can use play-mockws to simulate HTTP requests to external web services in your tests.

Example

// simulation of a GET request to http://dns/url
val ws = MockWS {
  case (GET, "http://dns/url") => Action { Ok("http response") }
}

await(ws.url("http://dns/url").get()).body == "http response"

The simulation of the HTTP response for the WS call is simply implemented with a standard Play Action.

An example how to structure an implementation to test it with MockWS can be found here.

Other examples can be found in the tests.

Usage

Add MockWS as test dependency in the build.sbt:

libraryDependencies += "de.leanovate.play-mockws" %% "play-mockws" % "0.9" % "test"

The last version can be found on Maven Central

And use it:

import mockws.MockWS

val ws = MockWS { ... }

Compatibility Matrix

MockWS is actually only compatible with Play 2.3.x., with Scala 2.10 or 2.11.

Developer info

Travis: Build Status

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.