Giriş
SpringCloud Contract WireMock kullanmaya gerek var mı bilmiyor. Çünkü karışık. Bunun yerine Java koduyla test REST uçları açmak daha kolay olabilir
Şu satırı dahil ederiz
<dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-contract-wiremock</artifactId><version>4.0.4</version></dependency>
Örnek
Şöyle yaparız
import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock;
@SpringBootApplication
@AutoConfigureWireMock()
public class SpringStubServerApplication {
public static void main(String[] args) {
SpringApplication.run(SpringStubServerApplication.class, args);
}
}Açıklaması şöyle
We need to add the AutoConfigureWireMock annotation to start a WireMock server in the context of the Spring application. This will bind the port, HTTPS port, and stub files and locations of the WireMock server when the Spring Boot application is started.
application.yaml şöyledir
spring:
application:
name: wiremock-service
main:
web-application-type: none
wiremock:
server:
files: classpath:/__files
stubs: classpath:/mappings
logging:
level:
org.springframework.cloud.contract.wiremock: debug
org.springframework.web.client: debug
com.github.tomakehurst.wiremock: tracefiles ile cevap olarak gönderilecek JSON dosyaları tanımlanır
stubs ile REST noktaları tanımlanır
Hiç yorum yok:
Yorum Gönder