How to run Junit TestSuites from gradle?


(James Pandavan) #1

I am trying to migrate from Ant build to Gradle in my project. There are a bunch of test cases(subclasses of junit.framework.TestCase) and few test suites (subclasses of junit.framework.TestSuite). Gradle automatically picked up all test cases to be run, but not test suites. However, I couldn’t find how to make gradle run a Junit3 TestSuite natively.

I probably could work around by calling ant.junit to run it. But, I feel there should be a native easy way to force gradle to pick them and run. I couldn’t find anything in the document . Am I missing something?


(Szczepan Faber) #2

Hello,

Did you try configuring the Test task include/exclude (and perhaps scanForTestClasses, too). See the docs here: http://gradle.org/docs/current/dsl/org.gradle.api.tasks.testing.Test.html

Cheers!


(James Pandavan) #3

Sorry for not following up earlier. I had scanForTestClasses disabled because I didn’t want to run all the test cases in the project. However I had included the TestSuite using include/exclude patterns.

To get it to work I used ant.junit eventually.