Search code examples
symfonybehat

Behat SymfonyExtension Configuration for specific Kernel


I have a specific Kernel for my application SpecificKernel.php under the app/SpecificKernel.php, I need to specify in my behat.yml to use this Kernel instead of the default one.

default:
    suites:
        first:
            type: symfony_bundle
            bundle: MyBundle
            mink_session: selenium2
            contexts:
                - MyBundle\Features\Context\FeatureContext

            # Should be placed somewhere in this file, but I do not know where
            #symfony2_extension:
                #kernel:
                    #path: app/SpecificKernel.php
    extensions:
        Behat\Symfony2Extension: ~
        Behat\MinkExtension:
            base_url:  http://www.example.local
            sessions:
                default:
                    symfony2: ~
                selenium2:
                    selenium2: ~

From the source code of SymfonyExtension i found that it should be set in symfony2_extension->kernel->path, but the problem is that I do not know where to put this configuration, I tried multiple ways and each time the default error Class AppKernel does not exist has arrived.

Can you please suggest where to put the symfony2_extension configurations in the behat.yml file.


Solution

  • Ok after 2 hours of work eventually I managed to do it, the problem was that you should specify not only the path but the class also. Finally I got something like this:

    default:
        suites:
            reglements:
                type: symfony_bundle
                bundle: MyBundle
                mink_session: selenium2
                contexts:
                    - MyBundle\Features\Context\FeatureContext
        extensions:
            Behat\Symfony2Extension:
                kernel:
                    path: app/SpecificKernel.php
                    class: SpecificKernel
            Behat\MinkExtension:
                base_url:  http://www.example.local
                sessions:
                    default:
                        symfony2: ~
                    selenium2:
                        selenium2: ~