imbo / behat-api-extension

API extension for Behat, used to ease testing of JSON-based APIs
MIT License
108 stars 42 forks source link

Config bug #47

Closed Tartare2240 closed 7 years ago

Tartare2240 commented 7 years ago

I am passing from Behat/WebApiExtension to this extension, but I'm struggling at the very beginning, on the config phase. I use almost the same behat.yml file working well with behat official extensions.

default:
    suites:
        default:
            contexts:
                - Tests\Behat\Hlc\HlcLegalBundle\FeatureContext
                - Imbo\BehatApiExtension\ServiceContainer\BehatApiExtension
    extensions:
        Behat\Symfony2Extension:
            kernel:
                env: test
        Imbo\BehatApiExtension:
            apiClient:
                base_uri: 'https://localhost'
        Behat\MinkExtension:
            base_url: https://gw.sse.hellocare-dev.com
            sessions:
                default:
                    symfony2: ~

For totally unknown reasons it triggers me a not implemented interface for no reason at all : Every context class must implement Behat Context interface, but Imbo\BehatApiExtension\ServiceContainer\BehatApiExtension does not. When I'm dumping the place where the interface is tested with var_dump($reflClass->getName(), $reflClass->getInterfaces()); I got :

string(57) "Imbo\BehatApiExtension\ServiceContainer\BehatApiExtension"
array(2) {
  ["Behat\Testwork\ServiceContainer\Extension"]=>
  object(ReflectionClass)#3993 (1) {
    ["name"]=>
    string(41) "Behat\Testwork\ServiceContainer\Extension"
  }
  ["Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface"]=>
  object(ReflectionClass)#3994 (1) {
    ["name"]=>
    string(68) "Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface"
  }
}

Any idea ?

christeredvartsen commented 7 years ago

Try changing the first part of the configuration to this:

default:
    suites:
        default:
            contexts:
                - Tests\Behat\Hlc\HlcLegalBundle\FeatureContext
                - Imbo\BehatApiExtension\Context\ApiContext
Tartare2240 commented 7 years ago

Perfectly working, thanks a lot !