Channels ▼

Open Source

Behavior-Driven Development With easyb

The Software Development Lifecycle with easyb

Software development with easyb is iterative and incremental in nature. The development team follows an outside-in, test-driven approach for development. A developer adopting easyb this methodology for software development would typically follow the steps shown in Figure 1.

Figure 1.

Requirements are a team effort in easyb. All stakeholders (business analysts, users, project managers, and developers) get together and come up with set of story files that describe requirements. A story file is created for every use case in the application. For example, for a typical Internet-banking application, the following story files would be created:

  • Login.story
  • ViewAccounts.story
  • FundsTransfer.story
  • BillPay.story
  • ServiceRequests.story
  • ChangePassword.story

Testing occurs throughout the process. Once story files are created, they are used to test application iteratively. Before development starts, all scenarios in the story files should fail. As the development progresses, the number of scenarios failing in story files declines. The development is said to be complete when all story files are executed successfully.

Developers can also use mock classes for pending implementations or for unit tests. As development progresses, mock classes will be replaced with actual code.

Implementation is the last phase of the lifecycle. The development team uses an outside-in and iterative approach to implement the application. The requirements described by the story files are mapped directly to the user interface or GUI of the application. Hence, developers start their development with the web-tier of the application. This is followed by development on the business-tier and data-tier. The entire effort is composed of in small segments with regression testing between each piece.

easyb as a Test Driver

easyb provides a Java-based platform for functional testing. The following are some of its key features:

  • It provides a framework to validate story files.
  • It features inherent Java support that allows testers to write OOP test classes.
  • Its specifications are written in Groovy and can be implemented using a Java runner.
  • It provides out-of-the-box reporting to display the test results.

As an example, I'll describe how to use easyb as a test driver for a login use case of Internet banking.

The first step is to set up easyb for Eclipse. If you haven't done so already, download Eclipse. Next, install the Groovy plugins. Finally, install the easyb plugins.

Now it's time to create a story file that describes the login requirements. This story file has two scenarios. The scenarios are described in simple English, which can be understood by all the stakeholders. The first scenario describes the login behavior when the correct username and password are entered; while the second scenario describes the login behavior when incorrect username and/or password are entered. Both scenarios are implemented with examples. The Java implementation is simple and explicit.

description "A User with valid credentials logs in to the netbanking application to view, edit, transfer money, pay bills etc "

narrative "description", {
	as_a "user with a valid netbanking credentials"
	i_want "to login to the netbanking web application "
	so_that "I can view, edit, transfer money, pay bills etc"

scenario "A user with valid credentials logs in successfully to the netbanking application",{
	given "A user with valid username and password",{
	when "The user signs in to the web interface", {
	then "the user login should be successful", {
		ValidateThat.application().hasUserLoggedIn().shouldBe true;	

scenario "A user with invalid credentials cannot log in to the netbanking application successfully",{
	given "A user with invalid username or/and password",{
	when "The user signs in to the web interface", {
	then "the user login should be unsuccessful", {
		ValidateThat.application().hasUserLoggedIn().shouldBe false;

Next, you must implement test logic. Support Java classes are created where actual test code reside. These classes follow OOP principles, see Figure 2.

Figure 2.

easyb test cases are executed using a Java runner. Easy B supports command-line, Ant, Maven, IntelliJ, and Eclipse to execute story files. The following is a utility written in Java to select and execute stories.

public void execute(){
		String[] args = new String[3];		
			args[1] = "-html";
			args[2] = "reports/Login.html";
		ConsoleConfigurator cc = new ConsoleConfigurator();
		Configuration configuration = cc.configure(args);
		if (configuration == null) {

		BehaviorRunner runner = new BehaviorRunner(configuration);
		String[] files = configuration.getFilePaths();

		boolean success = false;
		try {
			success = runner.runBehaviors(BehaviorRunner.getBehaviors(files,
		} catch (Exception e) {


The results of test execution in easyb can be displayed in HTML, XML, or as colored console output. These outputs can be chosen by giving –html, -xml, or –prettyprint as a command-line argument. Below are sample HTML(Figure 3) and console output obtained after executing a story file keeping the command-line argument as -html:


Running login story (Login.story)
FAILURE Scenarios run: 2, Failures: 1, Pending: 0, Time elapsed: 0.711 sec

	scenario "A user with invalid credentials cannot log in to the netbanking application successfully"
	step THEN "the user login should be unsuccessful" -- expected false but was true
2 total behaviors ran with 1 failure

Html Report:

Figure 3.

Related Reading

More Insights

Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.