Contributing behat tests to drupal.org?

Events happening in the community are now at Drupal community events on www.drupal.org.
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

Posted by nateswart (not verified) on June 11, 2014 at 9:29pm
nateswart's picture

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

Posted by greggles on June 12, 2014 at 12:37pm

Cool stuff. So...does this discover .feature files in modules? If so, what's the format/structure for those files?

Yes! By default, it looks for

Posted by nateswart (not verified) on June 12, 2014 at 11:51pm
nateswart's picture

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

Posted by skaught on June 12, 2014 at 8:27pm

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

Posted by nateswart (not verified) on June 12, 2014 at 11:47pm
nateswart's picture

Wonderful! Please offer any feedback you have!

If you're interested in

Posted by grasmash on June 13, 2014 at 12:09am

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

Posted by nateswart (not verified) on June 13, 2014 at 12:22am
nateswart's picture

... 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.

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

Posted by Mixologic on September 17, 2014 at 6:03pm

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.

Behat

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

AltStyle によって変換されたページ (->オリジナル) /