Command line test filter and custom test tasks are broken

Hello!

I have a project with unit tests. We decided to migrate from testng to JUnit 5 but do it in a couple of iterations. And now in our project tests for both platforms are present.

I handle it using the following build script:

def commonTestConfig =
{
    ignoreFailures = true

    ...
}

task testNGTests(type: Test) {
    useTestNG()
    configure commonTestConfig
    reports.html.destination = file("$buildDir/reports/testng")
}

task junitTests(type: Test) {
    useJUnitPlatform() 
    configure commonTestConfig
    reports.html.destination = file("$buildDir/reports/junit")
}


test {
    dependsOn testNGTests
    dependsOn junitTests
}

But if I try to run specific test from command line then build fails:

call gradle --warning-mode all test --tests my.package.LicenseTests 
Task :compileJava UP-TO-DATE
Task :processResources UP-TO-DATE
Task :classes UP-TO-DATE
Task :compileTestJava UP-TO-DATE
Task :processTestResources UP-TO-DATE
Task :testClasses UP-TO-DATE
Task :testNGTests UP-TO-DATE
Task :junitTests UP-TO-DATE
Task :test FAILED

FAILURE: Build failed with an exception.

* What went wrong: Execution failed for task ':test'.
No tests found for given includes: [my.package.LicenseTests](--tests filter)

I.e. the command above runs all tests(tasks testNGTests and junitTests) without applying provided filter. And after that tries to find tests to run in test task where no any one are supposed to run.

Is there a way to run both JUnit 5 and testng tests in Gradle cleanly, in a way preserving possibility to pass test filter from command line?