質問

has anybody encountered the following problem: behat apparently works fine, but it has no predefined steps: the result of

\tests> php .\behat\behat.phar -di

is empty even the file FeatureContext.php has no steps defined. My behat version is 2.4.0, it has been istalled with the help of PHAR, PHP Version is 5.4.9. Below are some details of my installation. The tree structure is as follows:

tests> dir
Directory: xxx\tests
Mode      Name                                       
d----     behat                                   
d----     features                                   
-a---     bootstrap.php                                   
-a---     phpunit.xml                                   
-a---     WebTestCase.php   

behat folder contains the following files:

tests> dir .\behat
Directory: xxx\tests\behat
Mode       Name
-a---     behat.phar                                   
-a---     mink.phar                                   
-a---     mink_extension.phar

while feature folder has only bootstrap directory

   tests> dir .\features
Directory: xxx\tests\features
    Mode     Name
    d----   bootstrap   

which contains the only file FeatureContext.php with the following content

<?php

use Behat\Behat\Context\ClosuredContextInterface,
    Behat\Behat\Context\TranslatedContextInterface,
    Behat\Behat\Context\BehatContext,
    Behat\Behat\Exception\PendingException;
use Behat\Gherkin\Node\PyStringNode,
    Behat\Gherkin\Node\TableNode;

class FeatureContext extends BehatContext
{
    public function __construct(array $parameters)
    {
        // Initialize your context here
    }
}
役に立ちましたか?

解決

Behat itself doesn't come with any predefined steps.

I can see you downloaded the mink extension and I'm guessing you're looking for steps which come with it (they're defined in the MinkContext). You didn't paste your behat.yml so I'm not sure if you actually enabled the extension. For more details follow the official docs.

Note: Steps defined in the MinkContext are a good start but once you finish playing with Behat, you should rather start writing your own steps and use the language of your business domain. Default MinkContext steps hardly ever reflect one's domain language.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top