Behat

Given the interest shown at Drupalcon Portland with both a crowded session and BOF, the next step of fostering a growing use of Behat is to have a group of interested users/developers/etc. Behat, if embraced by enough Drupal folks, has the potential to vastly improve the way we test Drupal websites.

Behat IS NOT unit testing nor a specification testing tool. Behat is a Scenario-oriented BDD framework with functional testing capabilities as part of a communication process between stake-holders and developers. Behat was created and is evolving as an agile planning and functional testing methodology. However, if you want to use it as unit testing or spec testing tool, you can, but keep in mind, that it wasn't intended to do ideologically. http://groups.drupal.org/unit-testing is a better place for discussion of unit-testing. Yes, there is some overlap, but that is because of the spectrum in the testing pyramid with the various types of testing: unit tests (base), functional/acceptance tests (middle), (G)UI tests (peak)

Behat was created to address black-box like, functional, user-observable behavior testing.

Bevan's picture

An easier way to run Gherkin tests?

I've used Behat on and off over the years. I love how useful the scenarios, gherkin and test results are, but hate maintaining the suite and writing step definitions; there so many arcane bugs that are hard to debug. And getting it running in CI environments is always a headache.

There must be an easier way. What about http://www3.obehave.io/?

Any other ideas?

Read more
e3g's picture

Any Behat examples for testing the RedHen CRM?

I am just getting started testing a new Redhen CRM instance using Behat. I'm using the Drupal API. While writing tests is coming along nicely, I don't see how to write tests that target the CRM's native objects, contacts, orgs, and lists.

The only connection that has turned up between Behat and Redhen from searches is three extremely basic tests that were the result of a sprint on Redhen Raiser. These tests don't target anything unique about the CRM but test basic things like logging in to Drupal.

I would like to be able to write a test along the lines of:

Given individuals:
Read more
mickaelperrin's picture

Random access error while trying to use access restricted pages

Hi all,

I have open an issue on Github, but this is maybe a better place to discuss this.

I have setup around twenty scenarios, all run fine when I run them directly and independently.

However, when I run my test suite in my CI pipeline (or locally), some of them randomly fails.

The screenshot taken when the test fails shows me that the user is considered as anonymous despite the fact that the authentification step was marked as successful.

Can someone give me some hints to try to debug this ?

I have no idea where to search as each time the failing tests differs.

Thanks,

Read more
jchin1968's picture

BeEdit - a Drupal 8 Behat Editor

As part of my Drupal 8 self-learning, I created a module called BeEdit which is a Behat editor suitable for non-technical users. It allows someone to create, edit and run Behat tests from the Drupal web application. You can get it here: https://www.drupal.org/sandbox/jchin1968/2829843

Read more
ushashree_m's picture

PHP Fatal error: Undefined class constant 'Symfony\Component\DependencyInjection\ContainerInterface::SCOPE_CONTAINER'

drupalextension
0% (0 votes)
behat
100% (3 votes)
Total votes: 3
clemens.tolboom's picture

How to test entity references and OG

We like to test Organic Group and their Content but are puzzled how to create related content.

Reading http://www.grasmash.com/article/behat-steps-organic-groups gives some clues but it's for Behat 2 and we did not manage to get that translated to Behat 3 yet.

Thinking about this basic need makes us wonder whether every site team has to add these steps themselves to their own context?

What would be the best way to share steps through the contrib modules?

Read more
thewilkybarkid's picture

Isolated-Drupal Behat Extension

We had some trouble using the Drupal Extension for Behat as scenarios aren't isolated from each other/what's already there, leading to sporadic failures. To counter this, we've put together an extension which causes each scenario to be run on a fresh install, leading to consistent (but slightly slower) builds. We've released it at https://github.com/elifesciences/isolated-drupal-behat-extension.

Read more
rgchi's picture

I can't seem to login as an admin on behat tests. Could anyone help point me in the right direction?

I'm trying to log create a scenario with a by logging in as a user in the administration role. I'm using the following as my first run to get my feet wet

$ cat first.feature
Feature: First
  Playing with features and exploring


@api
Scenario: Run cron
    Given I am logged in as a user with the "authenticated" role
    When I run cron
    And am on "admin/reports/dblog"
    Then I should see the link "Cron run completed"

However, on this I can't seem to get past the first step. When running this feature, I see the following error:

Read more
gram.steve's picture

Need to expose features available for Gherkin test writers

I need to find a way to create a list of all tests available for non technical gherkin test writers.

What are others using for this?

Read more
frankgil's picture

Forcontu is offering 10 x Drupal Training Scholarships

Forcontu is offering 10 x Training Scholarships for the Expert in Drupal 7 online course (valued at USD1350). If you want to apply, complete the form before April 15, 2015. On April 16 we will announce the 10 winners of a scholarship to join the course completely free. The course will be conducted from May 4 to December 4 (7 months).

More information and registration at:

http://www.forcontu.com/en/10-drupal-training-scholarships

Read more
lhridley's picture

Drupal MidCamp Training: Behavior Driven Development with Behat

Start: 
2015-03-19 09:00 - 17:00 America/Chicago
Event type: 
Drupalcamp or Regional Summit

Promet Source will be conducting a full day of training at Drupal MidCamp next week for Behavior Driven Development with Behat.

This training workshop is designed to help developers get started with the process of behavior driven development (BDD) in PHP using the Behat toolkit with Drupal specific extensions in order to align technical testing with business expectations when using Drupal as a development platform.

We will be focusing on Behat 3, and the latest version of the Drupal Extension for Behat in our workshop.

Read more
greggles's picture

Performance of Behat tests

When we started out using behat, things were great. Tests were easy to write and ran quickly. And then...over time, we got up to tests that took an hour to run. Which is too long.

We tried a few strategies:

  • Throwing more hardware at the problem - this cut test speed in half, but was constrained by CPU speed.
  • Reducing steps in afterScenario - we had placed a handful of different test cleanup steps into the afterScenario and those ran every time, even if they weren't needed. Optimizing those cut 30% off the test time for us.
Read more

Behat 3.0 tips/tricks

A place to link/stash Behat 3.0 tips and tricks.

Read more
sethcohn's picture

Behat 3.0 changes

So I'm working with the new Behat 3.0 (and the latest Drupal Extension), and discovering how much has changed... For example, Metasteps? Gone. Lots of changes to how you call stuff, and so on.

So a lot of the existing (and awesome) code out there you'll find googling no longer works.
One example: take a screenshot when a step fails? The code is obsolete. I know it's doable, but I'm not sure how yet.

Is there a good place (yet?) to discover the 3.0 way of doing things, and a repository of good example code for doing 'all the things'?

Read more
fen's picture

Junit formatter for Behat 3.x

Does anyone have the junit formatter working with behat 3.x?

I suppose there is a related question: is anyone using Behat 3.x with D7 site builds or is 2.x still the way to go?

Read more
eMuse_be's picture

Generic drupal feature files

Hi, I have set up a drupal structure using composer in git to kickstart our drupal development.
In the setup, behat and the DrupalExtension is integrated.

Our team will soon start writing tests for our websites. The generic tests (administrator permissions, Check if homepage works ...) will be put in our main git repo. I was wondering if there are other who have generic tests that are used on every drupal site, and if we could create a main repository ?

Read more
rachit_gupta's picture

Google hangout Session on Acquia Certification Program by Drupal Experts

Start: 
2014-12-27 11:00 - 12:30 Asia/Kolkata
Organizers: 
Event type: 
Training (free or commercial)

Dear All,

We are arranging for a Google hangout session where Drupal experts who have built the curriculum for Acquia certification and Drupal Developer who have taken the test will come on the same floor to talk on all you need to know about Drupal Acquia certification program. This will be an interactive session, you can ask questions and clarify your all your doubts.

Event URL - https://plus.google.com/events/c1bkr5q8id13k7nf6ncq7b214l0

Read more
moshe weitzman's picture

BADCamp 2014 BDD Summit - Accomplishments

Drupal Extension and Contrib

  • Jonathan Hedstrom et al worked on bug fixes and several feature additions to version 3 of the Drupal Extension. The Drush driver now allows global options to be passed through for all commands (such as --strict=0 for remote testing on Pantheon).
Read more
Xano's picture

Dinner with Drupal

Start: 
2014-10-28 17:30 - 21:00 Europe/Amsterdam
Event type: 
User group meeting

On Tuesday, October 28 we'll meer for another Dinner with Drupal. Between 17:30 and 18:30 a number of stand-up presentations will be given, after which we will have dinner and drinks at the venue. There are open spots for those who will want to demonstrate interesting new technologies or services, or who will want to pitch ideas. Please contact us, so we can put you in the schedule.

Read more
greggles's picture

Contributing behat tests to drupal.org?

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?

Read more
Subscribe with RSS Syndicate content

Behat

Group notifications

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