Get total test count in multi-module project from all modules


(Alexander Zagniotov) #1

Hi,

I am curious to know how to get total test count in multi-module project? I can get total test count per-module by doing something similar to the following:

...
  def testCounter = 0
  afterSuite { testDescriptor, testResult ->
     testCounter += testResult.getTestCount()
   }
  ...

What I want to do is to aggregate each module’s test count totals into one value… Any ideas?

Thank you


(Peter Niederwieser) #2

You can do something like:

def testCounter = 0
  allprojects {
    tasks.withType(Test) {
        afterSuite { testDescriptor, testResult ->
            testCounter += testResult.testCount
        }
    }
}

(Alexander Zagniotov) #3

Thanks!