Hazelcast: How to disable auto-discovery during tests?

I am building a Spring Boot project integrated with Hazelcast. To build the project I use mvn clean package command. In this maven build process, tests are run and Spring context wakes up. However, current active Hazelcast nodes in prod automatically discovers this node as a new node.

Is there a way to disable auto discovery only for test running at maven packaging process?

You could try to pass in the configuration parameter to disable the discovery during a test run. Depending on your used discovery the way is a little bit different though. You could, for example, use a Spring-alike Property Placeholder in the configuration and pass it as a JVM -D (system property) to the test runner.

Take a look at this page: http://www.baeldung.com/properties-with-spring

You will find a solution that suits you. My guess is you can use “5.4. The @TestPropertySource Annotation”