Вести себя - Контекстный класс не найден.


Это моя структура каталогов:

composer.json
composer.phar
vendor/
    bin/
        behat
tests/
    functional/
        behat.yml
        features/
            registration.feature
            bootstrap/
                FeatureContext.php

Я сделал:

cd tests/functional
../../vendor/bin/behat --init

, Который создал для меня базовую структуру. Это находится внутри behat.yml:

default:
  paths:
    features: '%behat.paths.base%/features'
    bootstrap:  '%behat.paths.base%/features/bootstrap'

Теперь я пытаюсь выполнить тесты BDD следующим образом:

vendor/bin/behat -c tests/functional/behat.yml

И я получаю:

  [RuntimeException]                                                       
  Context class not found.                                                 
  Maybe you have provided wrong or no `bootstrap` path in your behat.yml:  
  http://docs.behat.org/guides/7.config.html#paths                         



behat [--init] [-f|--format="..."] [--out="..."] [--lang="..."] [--[no-]ansi] [--[no-]time] [--[no-]paths] [--[no-]snippets] [--[no-]snippets-paths] [--[no-]multiline] [--[no-]expand] [--story-syntax] [-d|--definitions="..."] [--name="..."] [--tags="..."] [--cache="..."] [--strict] [--dry-run] [--rerun="..."] [--append-snippets] [--append-to="..."] [features]

Есть идеи, в чем проблема?

Я установил Behat через Composer. Это мой композитор.json:

{
    "name": "hello",
    "description": "Hello World",
    "minimum-stability": "dev",
    "require": {
        "php": ">=5.3",
        "zendframework/zendframework": "2.1.4",
        "doctrine/common": "dev-master#d7987c96675e153638729383577090feed9854f1"
    },
    "require-dev": {
        "phpunit/phpunit": "3.7.14",
        "behat/behat": "2.4.*@stable"
    }
}

Который я установил с помощью:

php composer.phar install --dev -o
Author: Richard Knop, 2013-04-10

2 answers

Вы инициализировали Behat, находясь в каталоге tests/functional, но пытаетесь запустить его из корневого каталога.

Исправьте свои пути:

default:
  paths:
    features: 'tests/functional/features'
    bootstrap:  'tests/functional/features/bootstrap'

Или запустите Behat из каталога tests/functional.

Я бы рекомендовал сохранить исходную компоновку файла (функции в корневом каталоге). Редактировать: На самом деле, я попытался настроить его сам, и он работал с конфигурацией, которую вы предоставили. Должно быть, вы делаете что-то еще, чего не указали в вопросе.

 6
Author: Jakub Zalas, 2016-11-17 11:01:59

Вот что сработало.

cd tests/functional
../../vendor/bin/behat --init
cd ../../
vendor/bin/behat -c tests/functional/behat.yml

С помощью этого конфигурационного файла:

default:
  paths:
    features: features
    bootstrap: features/bootstrap
 3
Author: Richard Knop, 2013-04-10 15:35:35