Questions tagged [nbehave]

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.

13 questions
18
votes
4 answers

How to see exactly what went wrong in Behave

We recently started using Behave (github link) for BDD of a new python web service. Question Is there any way we can get detailed info about the failure cause as tests fails? They throw AssertionError, but they never show what exactly went wrong.…
JOG
  • 5,590
  • 7
  • 34
  • 54
5
votes
4 answers

Any BDD success stories out there?

Having written a small article on BDD, I got questions from people asking whether there are any cases of large-scale use of BDD (and specifically NBehave). So my question goes to the community: do you have a project that used BDD successfully? If…
Dmitri Nesteruk
  • 23,067
  • 22
  • 97
  • 166
4
votes
4 answers

How BDD complements TDD

Since I heard about BDD(Behaviour driven development) I have been wondering if it complements TDD? Is it actually useful in web development? As a busy .net web developer is it worth spending time on BDD as well as TDD? When I have gone through it I…
Neel
  • 11,625
  • 3
  • 43
  • 61
2
votes
2 answers

Unit Testing -Isolation from external dependencies

While writing unit test, we always say that we need to ensure that code is always isolated from external dependencies. Below Moq has been used to provide a mocked object instead of a valid fluent nhibernate Session Factory. public class…
arjun
  • 625
  • 10
  • 27
1
vote
3 answers

Is there a .NET version of Concordion?

Apart from Fitnesse is there anything like concordion for .NET? Concordion is an open source framework for Java that lets you turn a plain English description of a requirement into an automated test David Peterson (the author of Concordion)…
Ian Ringrose
  • 51,220
  • 55
  • 213
  • 317
1
vote
1 answer

NBehave story output in resharper

I wrote a bunch of stories using NBehave. Now I have seen examples where the output is display in human readily format (see this example)Wayback machine link Is there any way to get this output in resharper?
RandomProgrammer
  • 1,570
  • 1
  • 14
  • 23
1
vote
1 answer

why test passes in vb? It should fail (it fails in the c# version)

I'm following examples in Professional.Test.Driven.Development.with.Csharp I'm converting the code from C# into VB. (this example is the start of chapter 7) Now having Public Class ItemType Public Overridable Property Id As Integer End…
GlutVonSmark
  • 284
  • 2
  • 9
1
vote
3 answers

Running NBehave plain text scenarious using TD.NET

Is this possible? Actually, any tips about running nbehave tests and integrating them with build server would be appreciated. Maybe there's a good alternatives?
Arnis Lapsa
  • 45,880
  • 29
  • 115
  • 195
0
votes
1 answer

How to write testcase using NBehave

I want every steps to write a Nbehave testcase. I have gone through the concept, but i don't know how to start and where to start. If any one can give an example with all the steps then it would be a great help.
Paritosh
  • 1
  • 3
0
votes
2 answers

Best Practices/Ideas for setting up system state when integration testing?

I have a number of C# integration tests written using the Given/When/Then style popularized by cucumber. I'm using a framework which basically works the same as NBehave. A recurring issue I'm facing is the issue of setup and wiring up all the…
Orion Edwards
  • 121,657
  • 64
  • 239
  • 328
0
votes
1 answer

NBehave and NUnit-2.5.5.10112 can work together?

I'm using Unit-2.5.5.10112. How can I use also NBehave, if it has dependency on an older version of NUnit? Should I ignore NBehave?
stacker
  • 14,641
  • 17
  • 46
  • 74
0
votes
3 answers

TestDriven.Net nunit.framework error

I am running TestDriven.Net version 2.23, NBehave version 0.4.0.133, and nunit version Unit 2.5.0.9122. I am also running the latest version of Resharper. Here is a snipet of test code: var address = new Address …
Chance Robertson
  • 468
  • 1
  • 7
  • 15
0
votes
2 answers

Using Mocks with multiple scenarios in NBehave

I'm using NBehave to write out my stories and using Rhino Mocks to mock out dependencies of the System(s) Under Test. However I'm having a problem resetting expected behaviour in my mock dependencies when moving from one scenario to the next. I only…