0

I'm trying to separate my gradle/spock tests into two groups:

  1. unit tests
  2. integration tests

My attempt was with jUnit's @Category. In build.gradle I created task for integration/e2e tests:

task e2eTest(type: Test) {
    useJUnit {
        includeCategories 'com.foo.bar.baz.E2ESpec'
    }
}

And marked my base abstract class with @Category(E2ESpec), but it doesn't work.

I've noticed that inheritance works, but only with single level inheritance:

@Category(E2ESpec)
abstract class AbstractSpec {...}

class ActualSpec extends AbstractSpec {...}

but doesn't work for cases like:

@Category(E2ESpec)
abstract class AbstractSpect {...}

abstract class AnotherAbstractSpec extends AbstractSpec {...}

class ActualSpec extends AnotherAbstractSpec {...}

Any idea how to fix it?

PS. I've many classes extending AbstractSpec and new classes appears, so I don't want @Category on each spec. Maybe pure gradle solution exists?

raduy
  • 482
  • 5
  • 11

1 Answers1

0

Create a new sourceset for integration tests, with a corresponding task. See How do I add a new sourceset to Gradle?

Greg Munt
  • 1
  • 2