Skip to content

Instantly share code, notes, and snippets.

@dantudor
Last active April 28, 2017 21:28
Show Gist options
  • Save dantudor/4594469 to your computer and use it in GitHub Desktop.
Save dantudor/4594469 to your computer and use it in GitHub Desktop.
Behat Tests in PHPUnit with Symfony 2.1
<?php
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\ConsoleOutput;
use Behat\Behat\Console\BehatApplication;
class BehatTest extends WebTestCase
{
/**
*/
public function testThatBehatScenariosMeetAcceptanceCriteria()
{
$features = '@AcmeDemoBundle';
try {
$input = new ArrayInput(array('--format' => 'progress', 'features' => $features));
$output = new ConsoleOutput();
$app = new \Behat\Behat\Console\BehatApplication('DEV');
$app->setAutoExit(false);
$result = $app->run($input, $output);
$this->assertEquals(0, $result);
} catch (\Exception $exception) {
$this->fail($exception->getMessage());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment