Hello, I am very new to StoryQ. Is there anyone who can tell me how to convert this NBehave to StoryQ ?
I am particularly interested with the Examples portion. I think this would very useful for recurring scenarios that depends on a few variables.
Thanks in advance!
Feature: add, subtract, divide and multiply
Scenario: Add numbers
Given I have entered [num1] into the calculator
And I have entered [num2] into the calculator
When I add the numbers
Then the sum should be [result]
| 1| 2| 3|
| -1| 2| 1|
| 1| -2| -1|
| -2| -3| -5|
Feb 20, 2010 at 6:19 AM
Try the code sample below.
Let me explain more fully. StoryQ runs within a test runner - currently this is either nUnit or MSTest. Because we want storyQ
to only be an abstraction layer this means that you can use the functions of the other runners. In this case, I went and had a look at nUnits functionality
and have leveraged its Sequential feature to do the job. So, that's the basis of the code samle. Note you'll need v2.5 for this feature.
Give it a go and let me know how this works for you - here are many ways to skin this cat but I have tried to make it as close as possible to the nBehave sample.
As an aside, you may find that nBehave is better for you if you want those types of tests. We found that it was too heavy and that's why StoryQ was written. Having said
that you may even mix and match. I usually use a mix of story tests, classical unit tests and FIT/fitnesse tests in my projects - it all depends on the audience.
public void MyTest(
[Values(1,-1, 1,-2)] int num1,
[Values(2, 2,-2,-3)] int num2,
[Values(3, 1,-1,-5)] int result)
private void IHaveEntered_intoTheCaculator(int num)
// your SUT code in each of these methods
private void IHaveEntered_IntoTheCalculator(int num)
private void TheSumShouldBe(int results)
Feb 20, 2010 at 11:05 AM
And similarly if you are using MSTest, you would just leverage it's data-driven unit testing (http://msdn.microsoft.com/en-us/library/ms182527.aspx). Just pass the arguments from the TestContext.DataRow
into your narrative methods. I recommend importing Linq to DataSets, because that gives you a nicer way to read fields off a untyped DataRow (http://msdn.microsoft.com/en-us/library/bb360891.aspx).
I think I will add these two examples to our wiki for documentation soon!