我已经设置了我的第一个Behat项目,但我遇到了定义除了FeatureContext以外的其他上下文的麻烦。它被创建(我用__construct中的一个骰子检查过),但是这些步骤没有被调用。无法识别自定义上下文的步骤
这里我的文件夹结构:
|-root
|-bin
|-features
|-FeatureContext.php
|-PageLoaderContext.php
|-page_loading.feature
我的package.json
{
"require": {
"behat/behat": "3.0.5",
"behat/mink-extension": "*",
"behat/mink-goutte-driver": "*",
"behat/mink-selenium2-driver": "*",
"behat/mink-zombie-driver": "*",
"symfony/http-kernel": "*"
},
"minimum-stability": "dev",
"config": {
"bin-dir": "bin"
}
}
这里是我的behat.yaml
default:
suites:
default:
contexts:
- PageLoaderContext
而我的特点
Feature: Tutte le pagine del sito caricano senza errori
Per poter usare il sito
Come utente
Ho bisogno che tutte le pagine carichino senza errori
Scenario Outline: Controlla il caricamento senza errori di pagine significative
Given I'm on "<url>"
When La pagina finisce di caricare
Then Dovrei ottenere uno status code HTTP pari a "<code>"
And Il "<selector>" della pagina dovrebbe contenere "<value>"
Examples:
| url | code | selector | value |
| ? | 200 | head title | Spagro |
PageLoaderContext.php
<?php
use Behat\Behat\Exception\PendingException;
class PageLoaderContext implements \Behat\Behat\Context\Context
{
/**
* @Given /^Carico la pagina "([^"]*)"$/
*/
public function caricoLaPagina($arg1)
{
throw new PendingException();
}
/**
* @When /^La pagina finisce di caricare$/
*/
public function laPaginaFinisceDiCaricare()
{
throw new PendingException();
}
/**
* @Then /^Dovrei ottenere uno status code HTTP pari a "([^"]*)"$/
*/
public function dovreiOttenereUnoStatusCodeHttpPariA($arg1)
{
throw new PendingException();
}
/**
* @Given /^Il "([^"]*)" della pagina dovrebbe contenere "([^"]*)"$/
*/
public function ilDellaPaginaDovrebbeContenere($arg1, $arg2)
{
throw new PendingException();
}
}
就像我说的,如果我实现FeatureContext的步骤,一切都很好,但是这是不行的。
请参阅:http://stackoverflow.com/help/tagging – Rizier123