My favorites | Sign in
Logo
                
Search
for
Updated May 06, 2009 by michael.minutillo
QuickStart  
NGourd in 3 minutes

Quick Start

Here is how to get up and running with NGourd in just 3 minutes (I haven't actually timed it)

Get NGourd

  1. Download the code
  2. Build it
  3. :)

Create your Feature project

  1. Open Visual Studio 2008
  2. Create a new "Class Library" project (call it "MyFirstFeatureProject" or something)

Create your first feature

  1. Add a new text file to your feature project. Call it "MyFirstFeature.feature". The extension is important
  2. In the properties dialog for the feature file, set the Build Action to Embedded Resource
  3. In your feature file enter the following:
  4. Feature: Reverse Polish Notation
    
      Scenario: Adding 2 numbers
        Given I have entered 3
        And I have entered 5
        When I click Add
        Then I should see 8
  5. Build the DLL
  6. Open a command prompt and navigate to where the feature assembly is and enter NGourd.exe MyFirstFeatureProject.dll
  7. You should see a heap of yellow indicating that all of your steps were not found.
  8. Congrats you now have a feature. Let's implement it

Implement your feature

  1. Add a reference to NGourd.Core to your feature assembly
  2. Add a new class called "CalculatorSteps" and make it inherit from NGourd.Core.Steps.StepContainerBase
  3. Add the following to the class
  4. Calculator calc;
    
    public override void Before()
    {
      calc = new Calculator();
    }
    
    [Step("entered (\d+)")]
    public void Enter(string number)
    {
      calc.Push(Int32.Parse(number));`
    }
  5. Add a Calculator class to your project with a Push method on it that takes a single integer parameter
  6. Run NGourd against your feature assembly again. You should see that the first two steps pass
  7. Add the last two steps to the step container like so:
  8. [Step("press Add")]
    public void PressAdd()
    {
      calc.Add();
    }
    
    [Step("should see (\d+)")]
    public void Verify(string expected)
    {
      Assert.That(Int32.Parse(expected) == calc.Result);
    }
  9. Implement the required methods of Add and Result on the Calculator class
  10. Compile and run NGourd against your feature project again
  11. You should see that everything is green.

Comment by zvolkov, May 19, 2009

Cool let me release the trolls :)

- having to do Int32.Parse all the time sucks. I guess C# is a strictly typed language.

- having NGourd.exe display results in command line is cool but not very useful. I'd rather see a wiki, sort of like the Fitness does.

Comment by troygoode, Jun 12, 2009

Regarding the Int32.Parse bit... check out the way Microsoft does its model binding magic in Asp.Net MVC to automagically cast strings into the format specified by method parameters

Comment by chathurangaw, Jun 19, 2009

This is great (y)... I was looking something similar like Cucumber to use with step definitions in .Net. I tried with Selenium RC and looks pretty promising.

Comment by jesus.garza.zambrano, Oct 29, 2009

shouldn't be [Step("click Add")]?


Sign in to add a comment
Hosted by Google Code