Community contributed extensions

Bhave – Web-based BDD framework based on Play!, WebDriver/Selenium2 and Knockout.js

Written by Ed Southey

Bhave allows you to easily create ‘Acceptance Tests’ of your web-accessible application, by turning natural language constructs into WebDriver commands to drive a real browser to interact with your application.

Motivation

BDD rocks. I won’t go into details on BDD specifics (Google is your friend). Selenese is all very well and good, but it still requires intimate knowledge of the syntax. Guiding the user through syntax or allowing them to create their own opens the door to a wider range of people being able to write and more importantly read the tests.

Installation

play install bhave 0.1
require:
    - play -> bhave 0.1:
        transitive: false

Bhave has a dependencies on Selenium and we don’t want those jars to be copied over to the application’s lib directory. That is why we specified transitive: false.

play dependencies --sync

Set Up

In your routes file you should include the following line to allow access through to the underlying Bhave module views etc:

*   /   module:bhave

In your application.conf there are three properties that can/should be included:

bhave.local.selenium.server.on=true

Whether to fire up a local Selenium server on startup. This is useful when you are developing/debugging. If you have a Selenium Grid or external Selenium Servers, then this is unnecessary.

bhave.local.selenium.server.port=9001

What port your local Selenium server should start on.

bhave.chrome.driver.path=

If you want to run tests in Chrome locally, then ChromeDriver (http://code.google.com/p/chromedriver/) needs to be on the path or specified here.

To persist your data, you’ll need to tell Play! to use a ‘real’ database, rather than the in-memory one by default. For performance/architectural reasons, you may want to use a MySQL/Postgres/Oracle database, see Play! documentation for configuring this easily. For testing/development purposes, a simple file-system based h2 database is fine. Change this line:

#db=mem

to

db=fs

Usage

Fire up your application with:

play run

Then simply access your application on http://localhost:9000/ (by default) and start creating tests!

Project Information

Source code: https://github.com/rugbyhead/bhave
Issue tracking: https://github.com/rugbyhead/bhave/issues