I need to test a big site written in ZF2. There is 443 test and about 10000 assertions. Testing with code coverage takes 6 hours! I think I found the problem: In controller's tests I use a dispatch method from AbstractHttpControllerTestCase. Time of execution of dispatch method is increasing after each test (from fractions of second to tens of seconds).
I use ZF 2.1.3, PHPUnit 3.7, PHP_CodeCoverage 1.2, Xdebug v2.2.1, PHP 5.4.7.
My dispatch method:
public function dispatch($url, $method = HttpRequest::METHOD_GET, $params = array())
{
$s = microtime(true);
parent::dispatch($url, $method, $params);
$end = microtime(true) - $s;
echo 'dis: '.$end."\n";
return $this->getApplication()->getMvcEvent()->getResult();
}
parent::dispatch is method from AbstractHttpControllerTestCase.
Sample of test:
$result = $this->dispatch('/archive/finance/older');
$this->assertControllerName('skycontent\controller\article');
$this->assertActionName('archive');
$this->assertParamValue('older', true);
$this->assertParamValue('category', 'finance');
$vars = (array) $result->getVariables();
$this->assertArrayHasKey('archivePosts', $vars);
Please help. Thanks.
Update:
I use process isolation and tests done in about 15 minutes (without code coverage) but I get error in the test that are marked as skipped:
PHPUnit_Framework_Exception: PHP Fatal error: Uncaught exception 'Exception' with message 'Serialization of 'Closure' is not allowed' in -:44
dispatch()
is inAbstractControllerTestCase
(Zend\Test\PHPUnit\Controller
) – Segura