Based on Dan North's initial vision of rbehave and utilizing the behavioral domain specific language (DSL) of Behavior Driven Design (BDD) we created the NBehave framework.
The primary goal of NBehave is a framework for defining and executing application requirement goals. These characterizations are modeled after the Behavioral Driven Design (BDD) terms Story, Scenario, Given, When, Then.
Relying on a syntax that is lightweight and targeted at product owners (a few "quotes" mostly), the code becomes an executable and self-describing requirements document.
The definitions within the actual unit test of the application coupled with the organic nature of the architecture and ubiquity of the domain model translates these concepts into becoming one cohesive amalgam.
With the help of Domain Driven Design, the code actually becomes what we have always wanted, living requirements that are constantly asserted on to ensure their viability and accuracy from inception to implementation.
Example Code
NBehave V0.5, C#, NUnit V2.4.3
using NBehave.Narrator.Framework;
using NBehave.Spec.NUnit;
[ActionSteps]
public class UserLogsInSuccessfully
{
// some code to setup _currentPage
// ...
[Given("I am not logged in")]
public void LogOut()
{
_currentPage.click("logout");
}
[When("I log in as $username with a password $password")]
public void LogIn(string username, string password)
{
_currentPage.click("login");
}
[Then("I should see a message, \"$message\"")]
public void CheckMessage(string message)
{
_currentPage.ToString().ShouldContain(message);
}
}
Along with a scenario:
Given I am not logged in
When I log in as Morgan with a password SecretPassw0rd
Then I should see a message, "Welcome, Morgan!"
And running the sceanrio as:
>NBehave-Console.exe NameOfDll.dll /sf=user_logs_in_successfully.feature
Produces the following output:
NBehave version 0.4.5.183
Copyright © NBehave 2007-2009
All Rights Reserved.
Runtime Environment -
OS Version: Microsoft Windows NT 5.1.2600 Service Pack 3
CLR Version: 2.0.50727.3603
Scenario: 1.user_logs_in_successfully
Given I am not logged in - PENDING
When I log in as Morgan with a password SecretPassw0rd - PENDING
Then I should see a message, "Welcome, Morgan!" - PENDING
P
Scenarios run: 1, Failures: 0, Pending: 1
Steps 3, failed 0, pending 3
Pending:
1) (1.user_logs_in_successfully): No matching Action found for "Given I am not logged in"
No matching Action found for "When I log in as Morgan with a password SecretPassw0rd"
No matching Action found for "Then I should see a message, "Welcome, Morgan!""
This has been reproduced without the express permission of the NBehave Team, but it is such a useful test tool, I hope they don't mind :)
Check out http://nbehave.codeplex.com/wikipage?title=Getting%20started to get started.