Is it better to specify all the parameters of a given in one line, or each parameter on a seperate line? i.e. which is better?
seperate And for each parameter
Scenario: some random scenario
Given a menu with a menu width of 19
And quit text of "quit"
And Fruit options of
|Text|
|some text|
When ...
Then ...
or all the paremters for the specific Given on one line
Scenario: Some scenario
Given a menu with quit text of "quit" and menu width of 19 and Fruit options of
|Text|
|Some text|
When ...
Then ...
This appears (and I hope I'm wrong) to have the following implications for how you write your bindings, as well as starts to influence how you write your class, which it shouldnt! i.e. first option (seperate AND for each parameter ) the binding is easier to write if your class has public properties that are set one by one after the object is created...
private Menu _menu;
[Given(@"a menu of fruit options")]
public void GivenAMenuOfFruitOptions(Table table)
{
string[] fruitOptions = table.GetColumn("Fruit");
_menu = new Menu(fruitOptions,null);
}
[Given(@"a menu width of (.*)")]
public void GivenAMenuWidthOf(string width)
{
_menu.Width = int.Parse(width);
}
[Given(@"a Quite text of ""(.*)""")]
public void GivenAMenuWidthOf(string quitText)
{
_menu.QuitText = quitText;
}
whereas option two ( all on one line) it's easier to have an object with a constructor that takes all the parameters as constructor arguments.
private Menu _menu;
[Given(@"a menu with quit text of ""(.*)"" and menu width of (\d+) and Fruit options of ")]
public void GivenAMenuOfFruitOptions(string quitText, int width, Table table)
{
string[] fruitOptions = table.GetColumn("Fruit");
_menu = new Menu(fruitOptions,width, quitText);
}
I feel as if I'm missing something, because the implementation of specflow should not influence the code I write, and I'm worried that #1 above will encourage overly stateful objects. I'm a functional stateless addict.
Any pointers will be most helpful.
txs in advance,
cheers, Alan