Quick StartHere is how to get up and running with NGourd in just 3 minutes (I haven't actually timed it) Get NGourd- Download the code
- Build it
- :)
Create your Feature project- Open Visual Studio 2008
- Create a new "Class Library" project (call it "MyFirstFeatureProject" or something)
Create your first feature- Add a new text file to your feature project. Call it "MyFirstFeature.feature". The extension is important
- In the properties dialog for the feature file, set the Build Action to Embedded Resource
- In your feature file enter the following:
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- Build the DLL
- Open a command prompt and navigate to where the feature assembly is and enter NGourd.exe MyFirstFeatureProject.dll
- You should see a heap of yellow indicating that all of your steps were not found.
- Congrats you now have a feature. Let's implement it
Implement your feature- Add a reference to NGourd.Core to your feature assembly
- Add a new class called "CalculatorSteps" and make it inherit from NGourd.Core.Steps.StepContainerBase
- Add the following to the class
Calculator calc;
public override void Before()
{
calc = new Calculator();
}
[Step("entered (\d+)")]
public void Enter(string number)
{
calc.Push(Int32.Parse(number));`
}- Add a Calculator class to your project with a Push method on it that takes a single integer parameter
- Run NGourd against your feature assembly again. You should see that the first two steps pass
- Add the last two steps to the step container like so:
[Step("press Add")]
public void PressAdd()
{
calc.Add();
}
[Step("should see (\d+)")]
public void Verify(string expected)
{
Assert.That(Int32.Parse(expected) == calc.Result);
}- Implement the required methods of Add and Result on the Calculator class
- Compile and run NGourd against your feature project again
- You should see that everything is green.
|
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.
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
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.
shouldn't be [Step("click Add")]?