토리맘의 한글라이즈 프로젝트 logo 토리맘의 한글라이즈 프로젝트

스프링 클라우드 컨트랙트 공식 레퍼런스를 한글로 번역한 문서입니다.

전체 목차는 여기에 있습니다.


WebFlux를 사용 중이라면, explicit 모드로도 테스트를 자동 생성할 수 있다. 다음은 explicit 모드를 설정하는 예시다:

Maven Gradle
<plugin>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-contract-maven-plugin</artifactId>
    <version>${spring-cloud-contract.version}</version>
    <extensions>true</extensions>
    <configuration>
        <testMode>EXPLICIT</testMode>
    </configuration>
</plugin>

WebFlux에서 테스트용 베이스 클래스와 RestAssured를 세팅하는 방법은 아래 코드를 참고해라:

@SpringBootTest(classes = BeerRestBase.Config.class,
        webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
        properties = "server.port=0")
public abstract class BeerRestBase {

    // your tests go here

    // in this config class you define all controllers and mocked services
    @Configuration
    @EnableAutoConfiguration
    static class Config {

        @Bean
        PersonCheckingService personCheckingService()  {
            return personToCheck -> personToCheck.age >= 20;
        }

        @Bean
        ProducerController producerController() {
            return new ProducerController(personCheckingService());
        }
    }

}

Next :
3.4.4. Custom Mode
CUSTOM 모드로 HttpVerifier 커스텀하기

전체 목차는 여기에 있습니다.

<< >>

TOP