Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
455 views
in Technique[技术] by (71.8m points)

gherkin - Specflow tables vs scenario outline

I've been working with specflow's scenario outlines where you define your tables as examples below the steps.

I've recently seen tables being used with scenarios as opposed to scenario outlines. Why would you use tables as opposed to scenario outline examples?

What are the benefit of tables? As far as I can see you have a dictionary that has little typesafety when compared to a typed parameter?

I'm sure I'm wrong about this but it seems better to use scenario outlines with tags. I'm sure I'm missing something here.

question from:https://stackoverflow.com/questions/65888427/specflow-tables-vs-scenario-outline

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Scenario Outlines (https://docs.specflow.org/projects/specflow/en/latest/Gherkin/Gherkin-Reference.html#scenario-outline) and Tables (called Data Tables - https://docs.specflow.org/projects/specflow/en/latest/Gherkin/Gherkin-Reference.html#data-tables) are two completely different things.

Scenario Outlines gives you the possibility to parameterize your Scenarios, so that you don't have to duplicate a Scenario a lot of times with only small changes.

Tables are a parameter for your step definitions. This gives you the possibility to pass more parameters to a step definition and in also a more structured way.
Yes, you can access the Table in an non-typesafe way. To get a more typesafe API, you can use the extension methods in the SpecFlow.Assist namespace. You can read more about it at https://docs.specflow.org/projects/specflow/en/latest/Bindings/SpecFlow-Assist-Helpers.html


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...