PHPUnit_Framework_TestSuite::count PHP Method

count() public method

Counts the number of test cases that will be run by this test.
public count ( boolean $preferCache = false ) : integer
$preferCache boolean Indicates if cache is preferred.
return integer
    public function count($preferCache = false)
    {
        if ($preferCache && $this->cachedNumTests !== null) {
            $numTests = $this->cachedNumTests;
        } else {
            $numTests = 0;
            foreach ($this as $test) {
                $numTests += count($test);
            }
            $this->cachedNumTests = $numTests;
        }
        return $numTests;
    }

Usage Example

 /**
  * A test suite started.
  *
  * @param \PHPUnit_Framework_TestSuite $suite
  *
  * @return void
  */
 public function startTestSuite(\PHPUnit_Framework_TestSuite $suite)
 {
     $suiteName = $suite->getName();
     $testCount = $suite->count();
     $context = array('suiteName' => $suiteName, 'testCount' => $testCount, 'operation' => __FUNCTION__);
     $this->suites[] = $suiteName;
     $this->stats[$suiteName] = array('tests' => 0, 'assertions' => 0, 'failures' => 0, 'errors' => 0, 'incompletes' => 0, 'skips' => 0, 'risky' => 0);
     $this->logger->notice(sprintf("TestSuite '%s' started with %d tests.", $suiteName, $testCount), $context);
 }
All Usage Examples Of PHPUnit_Framework_TestSuite::count