TestNG not forking test processes

Hey all,

I’m working with TestNG tests, implemented in a suite.xml file, and having trouble getting the test process to fork. Running with Gradle 2.6 right now (2.7 gave me weird XML parsing CNF errors when processing an imported ANT XML file, but that’s for another discussion)

        listeners << 'org.testng.reporters.XMLReporter'
        suites file("test/testng/RegressionSuite.xml")
        excludeGroups = [
  forkEvery = 100
  maxParallelForks = 1

When running this with over 2000 tests, I still see the same processes running the tests. New processes aren’t started at each additional 100 tests. Forking at every 1 test, or every 1000 tests doesn’t seem to change the behavior at all. Or is the expectation that it only creates a new process when there are multiple, parallel forks (in which case, begs the question, why there is a forkEvery option, if it’s only going to fork for number of maxParallelForks)?

I’m hoping this helps alleviate some of the OOM errors we’re getting in our (very large, very long running) test suite. I’m already bumping the memory up to 8g for the heap space, but that’s not enough, and going too much higher isn’t ideal for developer workspaces. The tests themselves don’t take much memory, but there may be memory leaks that have yet to be resolved.

Not sure if this is a limit of TestNG, or Gradle’s implementation of TestNG executors. I would think it would work, but I know that suite XML files can be wonky.


I ended up finding that it’s not that Gradle’s forking isn’t working, it’s that using a suite.xml file in TestNG can’t be forked. Probably because Gradle doesn’t know what’s going on inside the suite.xml.

My next step would be to parse the suite.xml and configure the class and package filtering in Gradle, or figure out a way to get the memory adjusted to let the tests run.