User Guide: Issues with having both unit tests and integration tests

In the User Guide, it says that anything in the “test” source set are unit tests. In the description of the “Test” task, it says that it executes all unit tests. I suppose this would be true, if we assume that everything in the “test” sourceSet is a unit test.

In Maven, there is a convention in place where the “Surefire” plugin, which processes unit tests, will only execute classes whose name ends with “Test”. The “Failsafe” plugin, which processes integration tests, will execute all the tests ending with “IT”.

It appears that Gradle’s convention is to assume that all test classes are unit tests. Separating this space into other kinds of tests requires redefining the “test” sourceSet and adding the “intTest” source set and defining your own naming pattern for each.

Have I understood this correctly?

If you want to keep sources, dependencies and compilation of unit and integration tests separate, declaring another source set is the way to go. (See ‘samples/java/withIntegrationTests’ in the full Gradle distribution.) If not, you just need to declare another ‘Test’ task with appropriate includes/excludes.