Here is a basic Hello World example of REST Assured with Spring Boot.

Rest-Assured is a Java-based library that is used to test REST Services. This library provides a headless Client to access REST services. We can therefore create highly customizable HTTP Requests to send to the Restful server. This enables us to test a large variety of Request combinations and in turn test different business logic.
Rest-Assured library also has the ability to validate the HTTP Responses received from the server. For example, we can verify the Status code, Status message, Headers and even the Body of the response. This makes Rest-Assured a very flexible library that can be used for testing.

First off, make sure you include REST Assured dependency in your Spring Boot Project:


Now suppose you want to test this REST Service:

package com.example.testrest;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

public class CustomerController {
    CustomerRepository repository;

    public List<Customer> findAll() {
        return repository.getData();

    public Customer findOne(@PathVariable int id) {
        return repository.getData().get(id);


Where the CustomerRepository class if the following one:

package com.example.testrest;

import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.List;
public class CustomerRepository {
    List<Customer> customerList = new ArrayList<Customer>();

    public void init(){
        customerList.add(new Customer(1, "frank"));
        customerList.add(new Customer(2, "john"));
    public List<Customer> getData() {
        return customerList;

Then, here is how you can test all the Endpoint methods with REST Assured:

package com.example.testrest;

import org.hamcrest.Matchers;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import static io.restassured.RestAssured.get;
import static;

public class DemoApplicationTests {

	public void testCustomerList() {

				.body("size()", is(2));

				.body("name", Matchers.equalTo("frank"));

				.body("name", Matchers.equalTo("john"));



You can find the full Spring Boot source code here:

FREE WildFly Application Server - JBoss - Quarkus - Drools Tutorials