Tools for testing HTTP services
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
contract-tests
examples/src/main/scala/com/wix/e2e/http/examples
http-testkit-client/src
http-testkit-core/src/main/scala/com/wix/e2e/http
http-testkit-marshaller-jackson/src
http-testkit-scala-test/src
http-testkit-server/src/main
http-testkit-specs2/src
http-testkit-test-commons/src/main/scala/com/wix/test/random
http-testkit/src/main/scala/com/wix/e2e/http
project
.gitignore
.travis.yml
CODE_OF_CONDUCT.md
HTTP_CLIENT.md
HTTP_CLIENT_MATCHERS.md
LICENSE
MARSHALLER.md
README.md
README.temp.md
WEBSERVER.md
WEBSERVER_MATCHERS.md
build.sbt
version.sbt

README.md

Build Status

HTTP Testkit

Overview

Wix Http Testkit is a library that will address many of the End-to-end testing concerns you might encounter.

Wix HTTP Testkit aims to be:

  • Simple Testing REST services or starting mock/stub servers is very simple and requires very few lines of code.
  • Fast Leveraging Akka-Http infrastructure, starting servers takes milliseconds.
  • Integrated: Other than providing a set of DSLs to support composing and executing REST HTTP calls and creating and configuring web servers, it also contains out of the box matcher libraries for Specs2 to easily validate each aspect of the tested flow.

Getting Started

Testing Client

Import DSL

import com.wix.e2e.http.client.sync._

Issue Call

    val somePort = 99123 /// any port
    implicit val baseUri = BaseUri(port = somePort)


    get("/somePath", 
        but = withParam("param1" -> "value") 
          and header("header" -> "value") 
          and withCookie("cookie" -> "cookieValue"))

Use Specs2 Matcher suite to match response

    import com.wix.e2e.http.matchers.ResponseMatchers._

    put("/anotherPath") must haveBodyWith("someBody")

For more info see Http Client Documentation and Response Matchers Suite.

Web Servers

Import Factory

    import com.wix.e2e.http.server.WebServerFactory._

Run an easily programmable web server

    val handler: RequestHandler = { case r: HttpRequest => HttpResponse()  }
    val server = aMockWebServerWith(handler).build
                                            .start()

Or run a programmable that will record all incoming messages

    val server = aStubWebServer.build
                               .start()

Match against recorded requests

  import com.wix.e2e.http.matchers.RequestMatchers._
  
  
  server must receivedAnyRequestThat(must = beGet)

For more info see Web Server Documentation and Request Matchers Suite.

Usage

HTTP-testkit version '0.1.19' is available on Maven Central Repository. Scala versions 2.11.x and 2.12.x are supported.

SBT

Simply add the wix-http-testkit module to your build settings:

libraryDependencies += "com.wix" %% "http-testkit" % "0.1.19"

Maven

<dependencies>
  <dependency>
    <groupId>com.wix</groupId>
    <artifactId>http-testkit_${scala.dependencies.version}</artifactId>
    <version>0.1.19</version>
  </dependency>
</dependencies>

Documentation

Contribute

Ideas and feature requests welcome! Report an issue or contact the maintainer directly.

License

This project is licensed under MIT License.