Project with multiple test task

We have two type test tasks test and integrationTest,

Now we have situatino where same class name with same package structure exist in both test and integrationTest directory and with this when I try to run test class from integrationTest it’s running from test:

We are using Spock framework with gradle (gradle version 5.6.4).

               --Unit Test1
               --Unit Test2
             --Integration Test1
             --Integration Test2

With above straucture when I run below command, it run test cases from test folder instead of integrationTest folder:
gradlew integrationTest --tests example.ClassA

When there is unique test class name than it’s working fine.
Is there any configuration that I’m missing?

How have you configured testClassesDirs? I’m guessing this is pointing to test classes instead of (or in addition to) your integration test classes

Yes I have configured testClassesDirs as below:
testClassesDirs = sourceSets.integrationTest.output.classesDirs
classpath += sourceSets.integrationTest.runtimeClasspath

But with same structure when I run integrationTest using IntelliJ (with Run Tests using: IntelliJ IDE). It’s running fine.