How to prevent JUnit test suite classes from being ran twice?

I’ve some test clases that’re part of a JUnit suite and hence running the suite runs them automatically. However, Gradle seems to be running them twice, presumably once as part of the JUnit suite and another as independent test files. I created a JUnit category and excluded that in the build file. However, now the classes are not executed at all - Gradle ignores the fact that the classes should still run as part of the JUnit suite.

The following does not work.

interface CDISuiteTest {
}
@org.junit.experimental.categories.Category(CDISuiteTest)
class MovieRipServiceTest {
@RunWith(Categories)
@Categories.IncludeCategory(CDISuiteTest)
@Suite.SuiteClasses([
MovieIndexAndSearchServicesTest,
MovieRipServiceTest
])
class CDITestSuite {
test {
    // Exclude integration tests and tests part of JUnit suites
    useJUnit {
        excludeCategories 'name.abhijitsarkar.moviemanager.util.CDISuiteTest'
    }
    includes = ['**/CDITestSuite*', '**/Test*'] as Set
}

No answers? :frowning:

Anyone, please?

one option might be to just exclude “MovieRipServiceTest”:

test{
...
excludes "**/MovieRipServiceTest"
}

cheers, Rene

Thanks for the answer. Usually the response time on this forum is pretty quick but I figured a new release might’ve slowed things down :slight_smile: MovieRipServiceTest is the JUnit suite - if I exclude it, isn’t the purpose lost? The individual test classes would still run but that is the exact opposite of what I want.

sorry, my fault. I mean exclude the testclass instead of the suite that contains the testclass. Sometimes a thread slips through our fingers. Next time we’ll try to achieve the “normal” pretty quick response time :wink:

Just to make sure I understand what you’re suggesting, you want the exclusion to be not by category but by individual test class names. I think when I did that before, the test classes never actually ran. My memory could be deceiving me - I’ll try that soon and report back.

That worked!