I've installed all of the necessary bundles with composer :
"behat/behat": "*",
"behat/symfony2-extension": "*",
"behat/mink": "*",
"behat/mink-bundle": "dev-master",
"behat/mink-extension": "*",
"behat/mink-goutte-driver": "*",
"behat/mink-selenium2-driver": "*",
"phpunit/phpunit": "4.1.*",
"phpunit/phpunit-selenium": ">=1.2",
Then I followed the documentation of the MinkBundle about Code Coverage (https://github.com/Behat/MinkBundle/blob/master/Resources/doc/coverage.rst)
But I can't get to have the coverage of my functionnal tests.
Here's an example of a ControllerTest :
namespace Keep\AccountBundle\Tests;
use Behat\MinkBundle\Test\MinkTestCase;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Output\NullOutput;
use Symfony\Component\Console\Input\ArrayInput;
use Doctrine\Bundle\DoctrineBundle\Command\DropDatabaseDoctrineCommand;
use Doctrine\Bundle\DoctrineBundle\Command\CreateDatabaseDoctrineCommand;
use Doctrine\Bundle\DoctrineBundle\Command\Proxy\CreateSchemaDoctrineCommand;
class UserControllerTest extends MinkTestCase
{
protected $base;
protected function setUp()
{
$this->base = $this->getKernel()
->getContainer()
->getParameter('mink.base_url');
//fixtures loading code
}
private function doLogin($username, $password) {
$session = $this->getMink()->getSession();
$session->visit($this->base.'/login');
$page = $session->getPage();
$page->fillField('username', $username);
$page->fillField('password', $password);
$page->pressButton('Login');
$this->assertEquals($this->base.'/', $session->getCurrentUrl());
}
public function testList() {
$this->doLogin('superadmin', 'superadmin');
$session = $this->getMink()->getSession();
$session->visit($this->base.'/account/user');
$this->assertEquals('200', $session->getStatusCode());
$this->assertCount(9, $session->getPage()->findAll('css', '#list-table tbody tr'));
}
}
When I run the command :
php phpunit.phar --coverage-html ./mink-report -c app/ src/Bundle/AccountBundle/Tests/Controller/UserControllerTest.php
All tests are OK, but the coverage of Controller is 0%. What is covered is only fixtures code (DataFixtures folder, and entities setters.