You most certainly can use Bahat with PHPUnit. I didn't try with PHPSpec, but I'm certain it's possible if you can access the logic that performs assertions. Typically any test framework would expose that logic for the "outside users".
/**
* @Then /^the magic should happen$/
*/
public function assertUnicornsExist()
{
// Make standard assertions through static calls…
PHPUnit_Framework_TestCase::assertTrue(true);
}
Not sure I get the full picture with regards to installation, but if you're using composer you can simply configure the "autoload" part to include your sources and contexts (if they are separate). Mine works pretty much out of the box:
{
"require": {
"behat/behat": "dev-master",
"behat/mink": "dev-master",
"behat/mink-extension": "dev-master",
"behat/mink-browserkit-driver": "dev-master",
"behat/mink-goutte-driver": "dev-master",
"phpunit/dbunit": "*"
},
"autoload": {
"psr-0": {
"": "src/"
}
}
}
Then you just include the vendor/autoload.php
. I recommend adding in a bootstrap that would run once using the @BeforeSuite
hook.
/**
* @BeforeSuite
*/
public static function setUpSuite(BeforeSuiteScope $scope)
{
// if not bootstrapped already, then include bootstrap with init'ing the autoloader, etc…
}
Also, if you're starting off with Behat 3 – the docs are not there yet, use http://behat.readthedocs.org/en/latest/. They contain the latest essentials and some decent examples.