title: Gradle custom task to run tests in loop
body: <p>My challenge is to run my custom tasks (E2E tests) step by step (sequentially)
  I have a few task like (yes, they are redundant)</p>
  <pre><code>task test1(type: Test) {
      group = E2E //var
      systemProperty &quot;spring.profiles.active&quot;, System.properties['spring.profiles.active']
      testLogging.showStandardStreams = true
      useJUnitPlatform {
          excludeTags 'regress'
      }
      include 'com/tests/lib/**'
      maxParallelForks = 1
  }
  </code></pre>
  <p>Other task i wish to run:</p>
  <pre><code>task test2(type: Test) {
      group = E2E //var
      systemProperty &quot;spring.profiles.active&quot;, System.properties['spring.profiles.active']
      testLogging.showStandardStreams = true
      useJUnitPlatform {
          excludeTags 'regress'
      }
      include 'com/tests/core/**'
      maxParallelForks = 1
  }
  </code></pre>
  <p>How can i run them sequentially?</p>
  <p>I was thinking about having one task which run them in a loop like:</p>
  <pre><code>task runTests {
      tasks.each {
          task -&gt;
              if (task.group == E2E) {
              println(&quot;Running E2E test: &quot; + task.name)
              dependsOn(task)
              println(task.name + &quot; finished. &quot; + task.getDidWork())
              }
      }
  }
  </code></pre>
  <p>However it seems gradle first read all of them and add it in its queue and then execute. Gradle output:</p>
  <pre><code>&gt; Configure project :intests
  Running E2E test: test1
  test1 finished. false
  Running E2E test: test2
  test2 finished. false
  </code></pre>