Restito

General

Category
Free
Tag
Testing
License
N/A
Registered
Aug 29, 2016
Favorites
2
Link
https://github.com/mkotsur/restito
See also
OkHttp Idling Resource
android-gradle-workshop
KotlinUnitTesting
Ristretto
selendroid

Additional

Language
Java
Version
0.8.2 (Jun 10, 2016)
Created
Oct 7, 2012
Updated
Jun 20, 2023
Owner
Mike Kotsur (mkotsur)
Contributors
Jeroen van Erp (hierynomus)
Thomas LÉVEIL (thomasleveil)
Ian Forsey (theon)
Krzysztof Wolny (vanta)
Libor Kramoliš (shamoh)
Alexander Albul (aalbul)
Marcel (HighTML)
brendan-hofmann
Mike Kotsur (mkotsur)
Ryan Yeats (ryeats)
Marcel Blonk (leblonk)
Patryk Zieliński (patryk-marcin-zielinski)
dependabot[bot]
Snyk bot (snyk-bot)
Rong-En Fan (rafan)
Michel Zanini (michelzanini)
16
Activity
Badge
Generate
Download
Source code

Restito - testing framework for REST clients

Restito is a tool for validating your code's interactions with REST services. It provides the Middle Way between hammering real HTTP services from your tests (thus making them brittle) and mocking too much and not testing the HTTP communication layer at all.

Inspired by Mockito and Rest Assured, Restito provides a handy DSL for:

  • Mimicking a behaviour of a REST server from your tests;
  • Recording your code's HTTP calls to the server and verifying them;
  • Integration with JUnit;
  • (m)TLS and HTTPS support;
  • Avoiding boilerplate code.

It helps you to test an application which makes calls to some HTTP service. Restito sets up a StubServer instance which responds to your application's Calls based on defined Stubs. A stub makes some Action to response when Condition is respected.

For more motivation, please read the Motivation section of the Developer's guide.

Developer's guide is the best place to start. FOR LOTS OF EXAMPLES CLICK -> HERE <- :-)

For more details you can also check Restito's javadoc.

Quick example:

package com.xebialabs.restito;

...

public class SimpleRequestsTest {

    private StubServer server;

    @Before
    public void start() {
        server = new StubServer().run();
        RestAssured.port = server.getPort();
    }

    @After
    public void stop() {
        server.stop();
    }

    @Test
    public void shouldPassVerification() {
        // Restito
        whenHttp(server).
                match(get("/demo")).
                then(status(HttpStatus.OK_200));

        // Rest-assured
        expect().statusCode(200).when().get("/demo");

        // Restito
        verifyHttp(server).once(
                method(Method.GET),
                uri("/demo")
        );
    }

}

Version compatibility

  • Use 1.x if you run JDK 11+;
  • Use 0.9.x if you run JDK 8+

Maven instructions

<dependency>
    <groupId>com.xebialabs.restito</groupId>
    <artifactId>restito</artifactId>
    <version>1.1.0</version>
</dependency>

Building instructions

$ gradle clean build