Behat / Symfony2Extension

Symfony2 extension for Behat
MIT License
392 stars 106 forks source link

Running behat with Symfony2Extension in Symfony 4 causes error #137

Closed bizmate closed 6 years ago

bizmate commented 6 years ago

similar to #41 When running behat in Symfony 4 i get

$ vendor/bin/behat -vvv

In ContainerBuilder.php line 1086:

[ReflectionException (-1)]
Class AppKernel does not exist

Exception trace: ReflectionClass->__construct() at /home/bizmate/Documents/siti-web/symfony-reusable-bundle/myreviews_reviews/vendor/symfony/dependency-injection/ContainerBuilder.php:1086 .....

When using configuration

default:
  formatters:
    progress: true
  suites:
    default:
      paths:
        features: features/reviewsService
      contexts:
        - ReviewsServiceContext:
            entityManager:  '@doctrine.orm.entity_manager'
            reviewsService: "@my_reviews_reviews.reviews"
  extensions:
    Behat\Symfony2Extension:
      kernel:
        env: test
        debug: true
        path: App\Kernel
    Behat\MinkExtension:
      base_url: 'http://www.acme.dev/app_test.php/'
      sessions:
        default:
          symfony2: ~

Ideas? The class App\Kernel exists and it is the default one provided in Symfony 4

sroze commented 6 years ago

See AppKernel vs App\Kernel 😉 How did you install Behat? Is it using Symfony Flex and its behat recipe?

bizmate commented 6 years ago

@sroze I am indeed running Flex and indeed used the recipe, if I remove the Symfony2Extension i can run the demo feature. I think i added the symfony2extension manually including some other behat things to my composer.json, like the formatter. But I need the symfony2extension to run behaviours against my service. I am aware about path: App\Kernel and I have also tried path: src/Kernel.php . In PSR-4 the skeleton app of flex puts the App namespace against src folder so either src/Kernel.php or App\Kernel should work.

I dont get why it mentions that message, does it want the Kernel to be called AppKernel or it is not happy with it?

bizmate commented 6 years ago

I have also tried using the class option:

class: Kernel

[ReflectionException (-1)]   
  Class Kernel does not exist 
bizmate commented 6 years ago

it works with

bootstrap: features/bootstrap/bootstrap.php
class: App\Kernel

but it cannot find the classes from my Bundle. I will close this issue and going to ask on the symfony slack if anyone knows there