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

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.

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

Thanks Peter for a quick reply. It helped.

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?

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.

Thanks for the clarification.

Thanks for the clarification.