Two things appear in my head:
Firstly, now I’m not worried about the heavy load of step definitions if they are short (oneliners) and called at some level of automation or DSL, which helps me automate the system under test. Watch a great presentation for inspiration.
So, in this sense, you can simply double the definitions of the steps with "overloads" for each case.
My first blow to the second solution was to stack attributes on top of others for the same method. This works, but not for additional parameters. (And additional parameters do not work very well with reference types like DateTime, but does DateTime work? Nullable). If you activate your steps, you will receive an error message:
Parameter counter mismatch! The binding method 'Class1.MyGiven (Int32, Int32, Int32)' must have 1 parameter
So, I return to my first solution like this:
[Given(@"case one with one int '(\d+)'")] public void Case1(int a) { // Short but sweet step definition that calls into automation layer } [Given(@"case one with two ints '(\d+)' and '(\d+)'")] public void Case2(int a, int b) { // Short but sweet step definition that calls into automation layer } [Given(@"case one with three ints '(\d+)' and '(\d+)' and also '(\d+)'")] public void Case3(int a, int b , int c) { // Short but sweet step definition that calls into automation layer }
Hopefully I didn’t cause too much confusion going back and forth. Sorry - there was no IDE on the bus :)
source share