Gradle is executing tests terribly slow because it is adding to much tests to the suite
<p>I have about 8 <strong>end-to-end-test</strong> classes that <strong>extend</strong> my <strong>abstract</strong> SpringContextLoadingTest class, which looks like this:</p>

<pre><code>@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
public abstract class SpringContextLoadingTest extends AbstractTestNGSpringContextTests {
}
</code></pre>

<p>I have main Application class with the <strong>@SpringBootApplication</strong> annotation.</p>

<p>As I use TestNG, I have some classes in one group ("channel A") and some in the other ("channel B").</p>

<p>I made gradle tasks for runnig separate groups:</p>

<pre><code>task runChannelA(type: Test) {
    forkEvery = 1
    useTestNG() {
        includeGroups "channel A"
    }
}
</code></pre>

<p>Without "forEvery = 1", there is a problem with busy ports when runnig more than 1 tests.</p>

<p>Thanks to this simple config below, I receive much more verbose output from gradle task execution:</p>

<pre><code>tasks.withType(Test) {
    testLogging.showStandardStreams = true
}
</code></pre>

<p>Without it, it would looked like after the tests are executed, application hangs for 2 minutes at closing the EntityManagerFactory, but this flag revealed that gradle picked up tests it wasn't asked to. For every test, no matter in which group it is in, gradle is logging:</p>

<pre><code>Gradle Test Executor 22 STANDARD_OUT
2016-12-21 17:10:00.115  INFO   --- [    Test worker] .b.t.c.SpringBootTestContextBootstrapper : Neither @ContextConfiguration nor @ContextHierarchy found for test class [mypackage.OtherTest], using SpringBootContextLoader
2016-12-21 17:10:00.141  INFO   --- [    Test worker] o.s.t.c.support.AbstractContextLoader    : Could not detect default resource locations for test class [mypackage.OtherTest]: no resource found for suffixes {-context.xml, Context.groovy}.
2016-12-21 17:10:00.143  INFO   --- [    Test worker] t.c.s.AnnotationConfigContextLoaderUtils : Could not detect default configuration classes for test class [mypackage.OtherTest]: DbCongestionExploratoryTest does not declare any static, non-private, non-final, nested classes annotated with @Configuration.
2016-12-21 17:10:00.455  INFO   --- [    Test worker] .b.t.c.SpringBootTestContextBootstrapper : Found @SpringBootConfiguration mypackage.Application for test class mypackage.OtherTest
2016-12-21 17:10:00.466  INFO   --- [    Test worker] .b.t.c.SpringBootTestContextBootstrapper : Using TestExecutionListeners: [org.springframework.test.context.web.ServletTestExecutionListener@9404cc4, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener@46876feb, org.springframework.test.context.support.DependencyInjectionTestExecutionListener@dd46df5, org.springframework.test.context.support.DirtiesContextTestExecutionListener@49e2c374]
</code></pre>

<p>And it takes so much time because I have a lot of other tests. This is happening after I can see in IntelliJ that tests that I wanted to execute have passed. For example I see after 25 seconds that the tests have passed, but because it is doing whatever the hell it is doing with every other test set up this way in my project, runChannelA takes more than 3 minutes. Funny thing is I can just stop the process during this strange behaviour, and the progress bar in IntelliJ just fills up to the end, and it is as nothing was going on, everything green and great.</p>

<p>Can someone help me with this?</p>