Is there a test suite concept in Gradle / Spock land?

Groovy / Gradle is here where Spock is used for unit testing.

Does Spock and / or Gradle support test suites or named test suites? For reasons beyond the scope of this question, there are certain Spock ( Specifications) tests that the CI server simply cannot run.

So, it would be great to divide all the tests of the Spock application into two groups:

  • " ci-tests"; and
  • " local-only-tests"

And then, perhaps, we could call them through:

./gradlew test --suite ci-tests

etc .. is that possible? If so, what does the configuration / config look like?

+4
source share
3 answers

, CI Spock @IgnoreIf().

: https://spockframework.imtqy.com/spock/docs/1.0/extensions.html#_ignoreif

, , CI , .

, :

@IgnoreIf ({sys.isCiServer})

+6

my-app-ci-test, build.gradle:

test {
    enabled = false
}
task functionalTest(type: Test) {
}

src/test/groovy ./gradlew functionalTest.

test functionalTest includes/excludes

test {
    exclude '**/*FunctionalTest.groovy'
}
task functionalTest(type: Test) {
    include '**/*FunctionalTest.groovy'
}
+1

If you are using Junit test run for Spock tests, you can use annotation @Category. An example of an article and official documentation :

 public interface FastTests {
 }

 public interface SlowTests {
 }

 public interface SmokeTests
 }

 public static class A {
     @Test
     public void a() {
         fail();
     }

     @Category(SlowTests.class)
     @Test
     public void b() {
     }

     @Category({FastTests.class, SmokeTests.class})
     @Test
     public void c() {
     }
 }

 @Category({SlowTests.class, FastTests.class})
 public static class B {
     @Test
     public void d() {
     }
 }
test {
    useJUnit {
        includeCategories 'package.FastTests'
    }
    testLogging {
        showStandardStreams = true
    }
}
0
source

All Articles