Contributing behat tests to drupal.org?

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
greggles's picture

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

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

greggles's picture

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

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

SKAUGHT's picture

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

nateswart's picture

Wonderful! Please offer any feedback you have!

If you're interested in

grasmash's picture

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

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.

mlncn's picture

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

Behat

Group notifications

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

Hot content this week