Spring Consul - disable for unit tests
<h1>Updated</h1>

<p>My class listed below (<code>ServiceDiscoveryConfiguration</code>) is never being utilized.  Even if I remove the <code>@EnableDiscoveryClient</code> to attempt to completely avoid the setup, it still attempts to connect to Consul.</p>

<p>The only thing that worked for me was removing the Consul Maven depdency completely:</p>

<pre><code>&lt;dependency&gt;
  &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;
  &lt;artifactId&gt;spring-cloud-starter-consul-all&lt;/artifactId&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
  &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;
  &lt;artifactId&gt;spring-cloud-starter-feign&lt;/artifactId&gt;
&lt;/dependency&gt;
</code></pre>

<p>What can I do to prevent Consul for running for unit tests if not through the profile and annotation setup?</p>

<h1>Original</h1>

<p>I have an application using Spring Consul.
I have a class set up to enable discovery like this:</p>

<pre><code>@Profile ("!" + Profiles.UNIT_TEST)
@Configuration
@EnableDiscoveryClient
public class ServiceDiscoveryConfiguration {
}
</code></pre>

<p>This <strong>should</strong> be disabling the Consul portion, if I am not mistaken.  The base test class (it's an <code>abstract</code> shared between all of my unit tests) is setup up with the following annotations.  This is where I <em>think</em> the problem is.</p>

<pre><code>@SpringBootTest (classes = Service.class)
@WebAppConfiguration
@TestExecutionListeners (...)
@DirtiesContext
@ActiveProfiles (Profiles.UNIT_TEST)
@Test (...)
public abstract class AbstractBootTest extends AbstractTestNGSpringContextTests {
  // ...
}
</code></pre>

<p>When I execute my tests I get:</p>

<blockquote>
  <p>Caused by: com.ecwid.consul.transport.TransportException:
  java.net.ConnectException: Connection refused</p>
</blockquote>

<p>This leads me to believe that the profile activation is not working or my syntax using the <code>!</code> operator on the <code>@Profile</code> specification is not doing what I thought it was supposed to be doing.  The root execution class itself has basic annotations including a <code>@ComponentScan</code> annotation that I know has the appropriate packages being scanned.</p>

<p>Assistance?</p>