Gradle does not support the old way of defining JUnit test suites


(dalewking) #1

Before JUnit4 the way that TestSuites were created in JUnit was to create a static method named suite that returned an instance of Test as in:

public static Test suite() {

TestSuite suite= new TestSuite();

suite.addTest(new MoneyTest(“testEquals”));

suite.addTest(new MoneyTest(“testSimpleAdd”));

return suite; }

Junit and Ant both support this. For the ability to migrate older codebases to Gradle, it needs to support this style of declaring test suites as well as the JUnit4 style.


(Peter Niederwieser) #2

Apparently, JUnit 3 suites aren’t recognized by test class scanning. Otherwise, they seem to work fine:

test {
  scanForTestClasses = false
  include "**/*Suite.class"
}

The ‘include’ isn’t strictly necessary, but will prevent test classes like ‘MoneyTest’ from being run twice.


(dalewking) #3

That does the job!