Fathom-test-tools provides JUnit4 FathomUnitTest and FathomIntegrationTest classes for starting your application in TEST mode on a randomly available http port.

The FathomUnitTest class starts a new instance of Fathom for each unit-test while the FathomIntegrationTest class starts and shares one instance of Fathom for each unit-test class.

Rest-Assured is automatically configured for this instance of your application allowing you to easily make http requests to your test instance and focus on unit and integration testing of your code.


Add the fathom-test-tools artifact.



package conf;

import fathom.test.FathomIntegrationTest;
import org.junit.Test;

import static com.jayway.restassured.RestAssured.*;

public class RoutesTest extends FathomIntegrationTest {

    public void testIndex() {

    public void testException() {

    public void testGetJSON() {

        // The JSON response should look like:
        // {
        //   "id" : 1,
        //   "name" : "Item 1"
        // }

        given().accept(JSON).when().get("/api/{id}", 1).then().body("id", equalTo(1));


    public void testGetXML() {

        // The XML response should look like:
        // <item id="1">
        //   <name>Item 1</name>
        // </item>

        given().accept(XML).when().get("/api/{id}", 1).then().body("item.@id", equalTo("1"));