Based on your question and comments on Jakub's answer, it looks like you are trying to write one step that can span multiple user journeys through your site. SpecFlow is not really intended for this, and this probably indicates that you should try and improve the structure of your scripts / functions.
To answer your question directly, I do not believe that there is a way to infer logical values โโbased on the existence of certain lines in the step definition.
If you want to continue this route, then your original example is probably the best choice.
I would recommend you not to use this approach, but instead take a look at restructuring your step definitions so that you can combine them together and reuse them in different scenarios. I'm really trying to think about an approximate definition of a step that would fit your decision.
An example of a multi-step approach might look like this:
Given I have logged in as an existing user //1 And I have started my 6-step registration process //2 And I have filled in valid address values on step 1 //3 And I have left the fields blank on step 2 //4 ... etc When I save my registration
And your steps:
- go to the login page, log in as a valid user
- go to step 1
- fill in the fields with valid input, click "next"
- click 'next'
You just need to make sure that each step is independent of the others as possible, so you can replace one step with a completely different one (for the new scenario) without affecting the others.
With this approach, you can still encounter complex (and possibly quite verbose) scenarios, but I think this is a better solution than trying to be smart and pack into one definition. You will probably end up with scripts that are not readable, and probably the code will be painful to read and maintain.
thecodefish
source share