unbroken-dome / gradle-testsets-plugin

A plugin for the Gradle build system that allows specifying test sets (like integration or acceptance tests).
MIT License
230 stars 50 forks source link

Test sets include Java plugin test source set by default #101

Closed pkoenig10 closed 4 years ago

pkoenig10 commented 4 years ago

I'm not sure if this intentional, but this can cause unexpected behavior because these tests sets are used to configure other plugins. For example, because of this the test source sets (testCompileClasspath, testRuntimeClasspath, and testAnnotationProcessor) are duplicated in the IDEA module scopes. These configurations are already added to the IDEA module scopes by the IDEA plugin.

Here a minimal reproduction of the issue:

build.gradle:

plugins {
    id 'java'
    id 'idea'
    id 'org.unbroken-dome.test-sets' version '2.2.1'
}

task testSetsInfo {
    doLast {
        testSets.each {
            println it
        }
    }
}

task scopesInfo {
    doLast {
        idea.module.scopes.TEST.plus.each {
            println it
        }
    }
}

Output:

$ gradle testSetsInfo

> Task :testSetsInfo
org.unbrokendome.gradle.plugins.testsets.dsl.PredefinedUnitTestSet@2822f626

BUILD SUCCESSFUL in 798ms
1 actionable task: 1 executed
$ gradle scopesInfo

> Task :scopesInfo
configuration ':testCompileClasspath'
configuration ':testRuntimeClasspath'
configuration ':testAnnotationProcessor'
configuration ':testCompileClasspath'
configuration ':testRuntimeClasspath'
configuration ':testAnnotationProcessor'

BUILD SUCCESSFUL in 659ms
1 actionable task: 1 executed
tkrullmann commented 4 years ago

Thanks for pointing this out. I think the IdeaModuleObserver should not be installed on the predefined unitTest set.