Default JUnit configuration is overridden by other test tasks

issue-resolved

(Steven Goris) #1

When I define useJUnit {} in a test task, the default test configuration is overridden. If I run gradle test, it takes the last includeCategories defined in my build script. Running the unitTest or integrationTest task works fine. I am using Gradle 2.13.

Example configuration:

test {
        useJUnit {
            includeCategories 'com.company.test.categories.UT'
        }
}
task unitTest(type: Test) {
        useJUnit {
            includeCategories 'com.company.test.categories.UT'
        }
}
task integrationTest(type: Test) {
        useJUnit {
            includeCategories 'com.company.test.categories.SIT'
        }
}
```

(Steven Goris) #2

Apparantly I was wrong, it was not the issue. Apparently the test classes are still loaded when using test categories, which can give confusing output with the spring junit runner. The test methods however are not executed.
I used testLogging.showStandardStreams = true in test {} and thought that this would be inherited by the rest of the tasks but it isn’t.