简体   繁体   English

执行集成测试时如何禁用Spring Cloud Zookeeper

[英]How to disable spring cloud zookeeper when executing integration test

The integration test tries to connect to zookeeper, when I test my code with TestRestTemplate and spring-cloud-zookeeper-discovery dependency. 当我使用TestRestTemplatespring-cloud-zookeeper-discovery依赖性测试代码时,集成测试会尝试连接到zookeeper。 If zookeeper is not running the test throws an exception. 如果zookeeper未运行,则测试将引发异常。

Here is simple project where you can reproduce the problem https://github.com/DenisGlot/disable-zookeeper-when-testing 这是一个简单的项目,您可以在其中重现问题https://github.com/DenisGlot/disable-zookeeper-when-testing

How can I make the test skip connecting to zookeeper part? 如何使测试跳过连接到Zookeeper的一部分?

Added bootstrap.properties in test/java/resources and put there 在test / java / resources中添加了bootstrap.properties并放置在那里

spring.cloud.service-registry.auto-registration.enabled=false
spring.cloud.zookeeper.discovery.enabled=false
spring.cloud.zookeeper.discovery.register=false

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 运行集成测试时禁用 Spring Cloud Sleuth? - Disable Spring Cloud Sleuth when running Integration Tests? 春季云流和动物园管理员 - spring cloud stream and zookeeper 如何将Apache ZooKeeper与Spring Cloud服务发现和负载平衡一起使用? - How to use Apache ZooKeeper with Spring Cloud service discovery and load balancing? 如何禁用谷歌云平台集成? - How to disable Google Cloud Platform integration? Spring:当使用@ComponentScan时,如何在集成测试中设置系统属性? - Spring: How to set system properties in integration test when @ComponentScan is used? 运行单元测试时如何自动禁用 Spring bean? - How to automatically disable a Spring bean when running a unit test? 在 Spring 集成测试中执行删除时如何测试约束冲突? - How can I test a constraint violation when performing a delete in a Spring integration test? 如何为 Spring Kafka Listener 创建集成测试 - How to Create Integration Test for Spring Kafka Listener 运行测试时禁用 Spring cloud consul - Disabling Spring cloud consul when running Test 如何使用@SpringBootTest 在 Spring 中运行集成测试 - How to run a integration test in Spring with @SpringBootTest
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM