2

I'm using the classpath suite library to automtically run all tests in a project, which works fine.

@RunWith(ClasspathSuite.class)
@SuiteTypes({RUN_WITH_CLASSES, TEST_CLASSES, JUNIT38_TEST_CLASSES})
@ClassnameFilters({"com.foo.bar.*"})
public class AllTests {
}

However, everytime I run AllTests I get this error:

java.lang.Exception: class 'com.foo.bar.AllTests' (possibly indirectly) contains itself as a SuiteClass

Any ideas how to get rid of this?

And yes, I've read JUnit: (possibly indirectly) contains itself as a SuiteClass but did not find an answer, since I'm not inheriting from AllTests in anyway.

Community
  • 1
  • 1
BetaRide
  • 16,207
  • 29
  • 99
  • 177

1 Answers1

3

Just move your AllTests class to package com.foo.

You have selected SuiteTypes=RUN_WITH_CLASSES (and set target package to com.foo.bar), so your AllTests runs AllTests over and over.

Maciej Dobrowolski
  • 11,561
  • 5
  • 45
  • 67
  • 1
    You are right that classpathsuite does find the `AllTests` which forms a circular dependency. Since I didn't like the solution of moving `AllTests` up the package hierachy, I excluded it by adding `"!com.foo.bar.AllTests"` to `@ClassnameFilters`. – BetaRide Jan 19 '15 at 07:29