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

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

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


WebFlux를 사용 중이라면, WebTestClient를 이용하면 된다. 다음은 테스트 모드에 WebTestClient를 설정하는 예시다:

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>WEBTESTCLIENT</testMode>
    </configuration>
</plugin>
contracts {
		testMode = 'WEBTESTCLIENT'
}

다음은 WebFlux에서 WebTestClient 베이스 클래스와 RestAssured를 설정하는 방법을 보여주는 코드다:

import io.restassured.module.webtestclient.RestAssuredWebTestClient;
import org.junit.Before;

public abstract class BeerRestBase {

	@Before
	public void setup() {
		RestAssuredWebTestClient.standaloneSetup(
		new ProducerController(personToCheck -> personToCheck.age >= 20));
	}
}

참고로, WebTestClient 모드가 EXPLICIT 모드보다 빠르다.


Next :
3.4.3. WebFlux with Explicit Mode
WebFlux 애플리케이션에서 explicit 모드로 테스트 자동 생성하기

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

<< >>

TOP