symfounya
symfounya

Reputation: 23

functionals tests with behat, mink and symfony2

I'm trying to test the bundles Behat and Mink, but I have a problem

Feature: Test      In order to test      As a developer      I Need To Be Able to submit a contact form

Scenario: Navigate to the welcome page # src \ Acme \ DemoBundle \ Features \ >essai.feature: 6      Given I am on "/ crud / Article"

Scenario 1 (1 undefined) 1 step (1 undefined) 0m0.243s

You Can Implement step definitions for undefined steps with snippets thesis:

     / **       * @ Given / ^ I am on "([^"] *) "$ /       * /      public function iAmOn ($ argument1)      {           throw new PendingException ();      }

But, I get nothing at all! nothing is executed and the file FeatureContext is not modified

Please help me to find a solution

Upvotes: 0

Views: 361

Answers (2)

Madness Method
Madness Method

Reputation: 41

It looks like you have not told Behat where to look for your main context file. You need to either explicitly load FeatureContext.php in your behat configuration file:

# config/behat.yml
default:
autoload: [ %paths.base%/../features/bootstrap ]
suites:
  default:
      paths: [ %paths.base%/../features ]
      filters:
      contexts:
          - FeatureContext

Or place FeatureContext.php exactly where Behat searches for it by default. From the "context class requirements" section of the Behat docs:

The context class should be discoverable and loadable by Behat. That means you should somehow tell Behat about your class file. Behat comes with a PSR-0 autoloader out of the box and the default autoloading directory is features/bootstrap. That’s why the default FeatureContext is loaded so easily by Behat. You can place your own classes under features/bootstrap by following the PSR-0 convention or you can even define your own custom autoloading folder via behat.yml.

Upvotes: 1

branchgabriel
branchgabriel

Reputation: 4251

If a step definition has any errors it can cause one of those "nothing happens" scenarios. It's aways best to copy the new step def from the console output and paste it in the your FeatureContext before you begin implementing it.

Upvotes: 0

Related Questions