I'm trying to separate my gradle/spock tests into two groups:
- unit tests
- 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?