Posted by greggles on June 11, 2014 at 9:24pm
Hello!
I'd like to start contributing some '.feature' files to modules on drupal.org and I'm trying to figure out if there's a standard way to do that so that they will be picked up when I run bin/behat to run my custom tests.
I see this documentation on subcontexts but it wasn't clear how to take advantage of that to run tests in a .feature file in a contrib.
Is there an example of a contrib module that has tests already and how to run them?
Comments
A few of us have been working
A few of us have been working (and sprinted just before Drupalcon last week) to get this wrapped up:
http://drupal.org/project/behatrunner
We've also created a sandbox for D8 and ported this D7 module into D8, hoping to merge it into core at some point. I'm heading up the efforts of a number of individuals. Our main goal is to get everyone heading in the same direction, so I'd love to hear feedback!
Cool stuff. So...does this
Cool stuff. So...does this discover .feature files in modules? If so, what's the format/structure for those files?
knaddison blog | Morris Animal Foundation
Yes! By default, it looks for
Yes!
By default, it looks for features definition in a /features subdirectory of your module. If you would like that to be different, there is hook_behat_info() you can implement to specify the location. Check behatrunner.module for an example. The module implements this hook itself, and supplies a sample feature in it's own /feature subdirectory.
Features are tracked and runnable at the scenario level. If you alter the feature definition files, just re-run the registration command: drush brm
Or even more specifically drush brm
I've been playing with this
I've been playing with this today. after spending a good chunk of yesterday with by QA guy to try to setup my system like his was...i got his tests running very quickly today with this.
Nice, to say the least.
Wonderful! Please offer any
Wonderful! Please offer any feedback you have!
If you're interested in
If you're interested in contributing .feature files for D8, please clone this D8 fork:
https://drupal.org/sandbox/madmatter23/2239057
The instructions on the project page will help you get set up. You need only to place files in a module's src/features directory for them to be discovered. No hook implementations needed.
... and to expand on what
... and to expand on what grasmash posted - both the behatrunner module (D7) and the work in the D8 sandbox are being worked on collaboratively and in parallel.
List of contributed Drupal modules that include behat tests?
Looking for models and best practices for writing Behat scenarios for Drupal in general, and for contributed modules in particular.
Also, contributed installation profiles: will Behat Runner find feature/*.feature files in a profile?
benjamin, agaric
Here's a bunch of examples
https://www.drupal.org/project/rooms
https://www.drupal.org/project/doobie <- these are the tests for drupal.org itself.
https://www.drupal.org/project/dkan
https://www.drupal.org/project/commons
https://www.drupal.org/project/commerce_drupalgap_kickstart
https://www.drupal.org/project/dcco
https://www.drupal.org/project/commerce_kickstart
https://www.drupal.org/project/devtrac
https://www.drupal.org/project/mvpcreator
https://www.drupal.org/project/restaurant
https://www.drupal.org/project/marketo_ma
https://www.drupal.org/project/drupalextension <- this is what you want for finding feature files
https://www.drupal.org/project/panopoly_test
https://www.drupal.org/project/wetkit
https://www.drupal.org/project/wetkit_tests
This is most of what I can find. I pretty much searched for projects that contained a FeatureContext.php file.