Fork me on GitHub

Java Project with JUnit Tests

Sample minimal configuration for Java Project with JUnit tests.

Test dependencies for generated contract verification tests

        <dependency>
            <groupId>com.jayway.restassured</groupId>
            <artifactId>rest-assured</artifactId>
            <version>2.9.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.jayway.restassured</groupId>
            <artifactId>spring-mock-mvc</artifactId>
            <version>2.9.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.toomuchcoding.jsonassert</groupId>
            <artifactId>jsonassert</artifactId>
            <version>0.4.7</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <version>2.4.1</version>
            <scope>test</scope>
        </dependency>

Project configuration for Accurest with JUnit tests and stub publishing

            <plugin>
                <groupId>org.springframework.cloud.contract</groupId>
                <artifactId>spring-cloud-contract-verifier-maven-plugin</artifactId>
                <version>${accurest-plugin.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>convert</goal>
                            <goal>generateStubs</goal>
                            <goal>generateTests</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <baseClassForTests>hello.BaseAccurest</baseClassForTests>
                </configuration>
            </plugin>

Base Test class

/**
 *
 *  Copyright 2013-2016 the original author or authors.
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package hello;

import com.jayway.restassured.module.mockmvc.RestAssuredMockMvc;

import org.junit.Before;

public class BaseAccurest {

    @Before
    public void setup() {
        RestAssuredMockMvc.standaloneSetup(new GreetingController());
    }

}