SpecFlow: Calling steps from steps from steps...aaarrrggghhhh!

Hackered
Saturday, July 26, 2014
by Sean McAlinden

I recently had the pleasure of fixing a number of broken SpecFlow tests and in the process was introduced a world where steps call steps which go on to call steps themselves... hang on 1 sec...

 

 

Shudder....

 

 

Ok, so it was fascinating at first, a four line gherkin script producing multiple pages of steps in the output... my fascination ended very quickly as the test wasn't working and I was tasked with making it work.

 

Luckily I've been around the block a few times and can spot dangerous rabbit holes and legacy beyond repair so with enough acceptance criteria in my arsenal, I wrote a new set of tests and damned the old crap into the abyss.

 

So the morale of this tale is:

 

Just because you can do something does NOT mean you should!

 

Next time you find yourselves writing steps that call steps that call steps etc., think to yourself... do I really want to write terrible code today?

What seems like a shortcut at the time will bite someone back in the future... don't make other peoples jobs suck and maybe they will do the same for you.

 

 

Rant over...

 

for now