Git Product home page Git Product logo

restito's Introduction

Restito - testing framework for REST clients

Build Status Maven Central Known Vulnerabilities

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

restito's People

Contributors

aalbul avatar brendan-hofmann avatar dependabot[bot] avatar hierynomus avatar hightml avatar leblonk avatar michelzanini avatar mkotsur avatar patryk-marcin-zielinski avatar rafan avatar ryeats avatar shamoh avatar snyk-bot avatar theon avatar thomasleveil avatar vanta avatar

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.