This project is read-only.

Fluent Syntax & Examples/Tables

Aug 17, 2012 at 10:59 AM

Should a developer uses fluent syntax to create feature, stories, and scenarios, is there any way to specify examples and tables ? Or NBehave support tables & examples in the .feature file only?




Aug 20, 2012 at 9:31 PM

There is no good way to run tables & examples using the fluent api (patches are welcome).
The only reasonable way I came up with is using nunits TestCase attribute.

        [TestCase(1, 1, 2)]
        [TestCase(1, 2, 3)]
        [TestCase(1, 3, 4)]
        public void should_add_x_plus_y_correctly(int x, int y, int expected)
            Calculator calculator = null;

                .Given("a calculator", () => calculator = new Calculator())
                .And("I have entered x into the calculator", () => calculator.Enter(x))
                .And("I have entered y into the calculator", () => calculator.Enter(y))
                .When("I add the numbers", () => calculator.Add())
                .Then("the result should be z", () => calculator.Value().ShouldEqual(expected));