JUnit categories support from 1.6 doesn't work with an integrationTest task


(Marcin Zajączkowski) #1

I’ve tried to use support for @Categories (GRADLE-2111) in JUnit/Spock tests and it works fine in a default test task, but with the same configuration it doesn’t in my integrationTest task - all tests are run.

task integrationTest(type: Test, dependsOn: "test") << {
        include '**/*IT.*'
          useJUnit {
            includeCategories 'my.package.SomeTestGroup'
        }

Is it required to define integrationTest task in some other way to make [include|exclude]Categories work?

Gradle 1.6-20130405014639+0000. JUnit 4.11.


(Peter Niederwieser) #2

Your task declaration is incorrect. You have to omit the ‘<<’.


(Marcin Zajączkowski) #3

Thanks Peter for a quick reply. It helped.


(Marcin Zajączkowski) #4

Btw, I took with from http://www.gradle.org/docs/current/userguide/tutorial_gradle_command_line.html

task compileTest(dependsOn: compile) << {
    println 'compiling unit tests'
}

Is it some specific case or a documentation should be updated?


(Peter Niederwieser) #5

The docs are correct. The ‘println’ is supposed to be run in the execution phase; your code (‘include’, etc.) needs to be run in the configuration phase. Configuration and execution phase has a bit more on this.


(Marcin Zajączkowski) #6

Thanks for the clarification.


(Marcin Zajączkowski) #7

Thanks for the clarification.