Depending on if my FeatureContext
class extends RawMinkContext
or MinkContext
I'm having issues running Behat tests.
Here's my FeatureContext.php
<?php
use Behat\Behat\Context\ClosuredContextInterface;
use Behat\Behat\Context\TranslatedContextInterface;
use Behat\Behat\Context\Context;
use Behat\Behat\Context\BehatContext;
use Behat\Behat\Exception\PendingException;
use Behat\Gherkin\Node\PyStringNode;
use Behat\Gherkin\Node\TableNode;
use Behat\MinkExtension\Context\MinkContext;
use Behat\MinkExtension\Context\RawMinkContext;
use Behat\Behat\Context\SnippetAcceptingContext;
use Behat\Mink\Driver\Selenium2Driver;
use Behat\Behat\Hook\Scope\AfterStepScope;
use Goutte\Client;
class FeatureContext extends MinkContext implements Context, SnippetAcceptingContext {
/**
* Initializes context.
* Every scenario gets its own context object.
*
* @since 1.0.0
*
* @param array $parameters context parameters (set them up through behat.yml)
* @return null
*/
public function __construct() {
}/* __construct() */
}
?>
and my behat.yml
default:
suites:
default:
path: %paths.base%/features
contexts:
- FeatureContext
- Behat\MinkExtension\Context\MinkContext
- Behat\MinkExtension\Context\RawMinkContext
extensions:
Behat\Symfony2Extension: ~
Behat\MinkExtension:
base_url: 'http://somesite.com'
goutte: ~
javascript_session: selenium2
files_path: 'vendor'
selenium2: ~
sessions:
default:
goutte: ~
goutte:
goutte: ~
selenium2:
selenium2: ~
symfony2:
symfony2: ~
formatters:
html:
output_path: %paths.base%/reports
PHP Fatal error: Call to a member function getSession() on a non-object in /home/behat/composer/vendor/behat/mink-extension/src/Behat/MinkExtension/Context/RawMinkContext.php on line 101
If I extend
RawMinkContext
instead of MinkContext
then the tests run, but it adds (blank) versions of the default steps that are defined in MinkContext (i.e. If I am on [url] or When I go to [url] etc. ).
If I run behat -c ./config/behat.yml
(or, just ./behat.yml
- I have an identical behat.yml file in both locations as I wasn't sure it was being used properly) I get the same results as above. I'm almost certainly doing something dumb...
My composer.json
for reference:
{
"name": "behat mink skeleton",
"require": {
"behat/behat": "*",
"behat/mink-extension": "*",
"behat/mink-browserkit-driver": "*",
"behat/mink-goutte-driver": "*",
"behat/mink-selenium2-driver": "*",
"bossa/phpspec2-expect": "*",
"teaandcode/behat-guzzle-extension": "*",
"sauce/sausage": ">=0.5",
"sauce/connect": ">=3.0",
"emuse/behat-html-formatter": "dev-master"
},
"minimum-stability": "dev",
"config": {
"bin-dir": "bin/",
"github-oauth": {
"github.com": "ac1dd3678488663ccc1ba02a5d1d474e1a78bb93"
}
}
}
If you extend MinkContext in FeatureContext then remove MinkContext from behat.yml. behat.yml file should contain only the local context under contexts section, in your case you don't need MinkContext or RawAwareContext, only FeatureContext.