How to duplicate/clone a gradle task?

Viewed 19

I am using the new JVM Test Suite plugin to create a regression test suite (including a dedicated source set and dedicated dependencies).

testing {
    suites {    
        regressionTest(JvmTestSuite) {
            dependencies {
                implementation project
                implementation 'org.assertj:assertj-core:3.22.0'
            }

            targets {
                all {
                    testTask.configure {
                        sourceCompatibility = '17'
                        targetCompatibility = '17'
                        useJUnitPlatform {
                            includeTags 'check'
                        }
                    }
                }
            }
        }
    }
}

This generates a 'regressionTest' task that runs the tests on my new source set. So far so good.

Now I need to be able to run that task with a different includeTags for JUnit, but I can't find a good way to do so.

I found https://github.com/gradle/gradle/issues/6172 and JUnit5 tag-specific gradle task, but those only work for the duplicating the standard test task. If I do so, it would not run with the correct dependencies and the correct source set.

What's a good way to create a new test task with specific JUnit5 tags when using the JVM Test Suite plugin ?

0 Answers
Related