Using zend-test with Behat

zend-mvc
behat
zend-test

#1

I’ve been successfully using Behat with zend-test, but only by making my contexts inherit from AbstractHttpControllerTestCase. This means I can only have one context per Behat suite.

This limits my ability to organize context code.

Is there a more clever way to use the two together? Ideally I’d like to inject a shared instance of AbstractHttpControllerTestCase into each context, but as far as I can tell Behat doesn’t support this.


#2

There are at least two answers (yay!)

And Behat’s own “helper containers”:


#3

Note that we wrote the roave/behat-psr11extension because the built-in only works with a symfony container.


#4

Ah, thanks for the clarification Marco.

I asked just that question in the Q&A channel on zf slack (at the risk of making a loop: https://zendframework.slack.com/archives/C4QB9N6E8/p1503035537000098 )

I’m not seeing the use case for a full-fledged container with Behat - I only ever want to inject some top-level, application level object.

Maybe I’m suffering from lack of imagination.


#5

Behat is not just an E2E scenario verification tool: you can use it in isolated portions of your service layer.