Skip to content

Commit

Permalink
docs: use scenario outline for scenarios with examples (#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
hedhyw authored Sep 16, 2023
1 parent 05f6f3d commit 6251e1f
Show file tree
Hide file tree
Showing 13 changed files with 28 additions and 20 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ The generator is very customizable, it is possible to customize an output for an
**Given** [feature](internal/generator/examples/readme.feature) [[reference](https://cucumber.io/docs/gherkin/reference/)]:
```feature
Feature: Application command line tool
Scenario: User wants to see usage information
Scenario Outline: User wants to see usage information
When the application is started with <flag>
Then usage should be printed <printed>
And exit status should be <exit_status>
Expand Down
16 changes: 8 additions & 8 deletions internal/app/app.feature
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Feature: Application command line tool
Scenario: User wants to generate the output in given format
Scenario Outline: User wants to generate the output in given format
When <format> is given
And <feature> is provided
Then the output should be generated
Expand All @@ -11,21 +11,21 @@ Feature: Application command line tool
| app.feature | invalid | does not |
| notfound.feature | raw | does not |

Scenario: User wants to see usage information
Scenario Outline: User wants to see usage information
When <flag> is provided
Then usage should be printed
Examples:
| <flag> |
| --help |

Scenario: User wants to list built-in templates
Scenario Outline: User wants to list built-in templates
When <flag> is provided
Then templates should be printed
Examples:
| <flag> |
| --list |

Scenario: User wants to use custom template
Scenario Outline: User wants to use custom template
When <template> is provided
And <feature> is provided
Then the output should be generated
Expand All @@ -35,15 +35,15 @@ Feature: Application command line tool
| app.feature | @/std.struct.v1.go.tmpl |
| app.feature | @/std.simple.v1.go.tmpl |

Scenario: User wants to set custom package
Scenario Outline: User wants to set custom package
When <package> is provided
Then the output should contain <package>
Examples:
| <package> |
| app_test |
| example_test |

Scenario: User wants to generate a permanent json output
Scenario Outline: User wants to generate a permanent json output
When -format is json
And -permanent-ids is <TheSameIDs>
Then calling generation twice will produce the same output <TheSameIDs>
Expand All @@ -56,15 +56,15 @@ Feature: Application command line tool
When flag -invalid is provided
Then an error is returned

Scenario: User asks for a version
Scenario Outline: User asks for a version
When <flag> is provided
Then version is printed
Examples:
| <flag> |
| --version |
| -version |

Scenario: User specifies a file, but the file is not found
Scenario Outline: User specifies a file, but the file is not found
When inexistent <template> is provided
And <feature> is provided
Then the user receives an error
Expand Down
10 changes: 9 additions & 1 deletion internal/docplugin/goplugin/goplugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func (p GoPlugin) handleStruct(
val.PluginData[dataFieldGoparallel] = p.args.Parallel
p.processRuleBackground(val)
case model.Scenario:
val.PluginData[dataFieldGoName] = p.aliaser.NameAlias(val.Keyword)
val.PluginData[dataFieldGoName] = p.aliaser.NameAlias(formatScenarioKeyword(val.Keyword))
val.PluginData[dataFieldGoValue] = p.aliaser.StringValue(val.Name)
val.PluginData[dataFieldGoType] = string(goTypeString)
val.PluginData[dataFieldGoparallel] = p.args.Parallel
Expand All @@ -191,6 +191,14 @@ func (p GoPlugin) handleStruct(
return nil
}

func formatScenarioKeyword(keyword string) string {
if strings.ToLower(keyword) == "scenario outline" {
keyword = "Scenario"
}

return keyword
}

func (p GoPlugin) processFeatureBackground(f model.Feature) {
var hasBackground bool

Expand Down
2 changes: 1 addition & 1 deletion internal/generator/examples/bool.feature
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Feature: Type determinatiopn
Scenario: All type are determinated
Scenario Outline: All type are determinated
When generator completed
Then correct types are shown
Examples:
Expand Down
2 changes: 1 addition & 1 deletion internal/generator/examples/default/bool.feature.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"PluginData": {}
},
"Tags": [],
"Keyword": "Scenario",
"Keyword": "Scenario Outline",
"Name": "All type are determinated",
"Description": "",
"Steps": [
Expand Down
2 changes: 1 addition & 1 deletion internal/generator/examples/default/issue_26.feature.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"PluginData": {}
},
"Tags": [],
"Keyword": "Scenario",
"Keyword": "Scenario Outline",
"Name": "Just a hello world",
"Description": "",
"Steps": [],
Expand Down
2 changes: 1 addition & 1 deletion internal/generator/examples/default/readme.feature.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"PluginData": {}
},
"Tags": [],
"Keyword": "Scenario",
"Keyword": "Scenario Outline",
"Name": "User wants to see usage information",
"Description": "",
"Steps": [
Expand Down
2 changes: 1 addition & 1 deletion internal/generator/examples/issue_26.feature
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Feature: Issue example
Scenario: Just a hello world
Scenario Outline: Just a hello world
Examples:
| <name> |
| hello world |
2 changes: 1 addition & 1 deletion internal/generator/examples/parallel/bool.feature.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"PluginData": {}
},
"Tags": [],
"Keyword": "Scenario",
"Keyword": "Scenario Outline",
"Name": "All type are determinated",
"Description": "",
"Steps": [
Expand Down
2 changes: 1 addition & 1 deletion internal/generator/examples/parallel/issue_26.feature.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"PluginData": {}
},
"Tags": [],
"Keyword": "Scenario",
"Keyword": "Scenario Outline",
"Name": "Just a hello world",
"Description": "",
"Steps": [],
Expand Down
2 changes: 1 addition & 1 deletion internal/generator/examples/parallel/readme.feature.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"PluginData": {}
},
"Tags": [],
"Keyword": "Scenario",
"Keyword": "Scenario Outline",
"Name": "User wants to see usage information",
"Description": "",
"Steps": [
Expand Down
2 changes: 1 addition & 1 deletion internal/generator/examples/readme.feature
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Feature: Application command line tool
Scenario: User wants to see usage information
Scenario Outline: User wants to see usage information
When the application is started with <flag>
Then usage should be printed <printed>
And exit status should be <exit_status>
Expand Down
2 changes: 1 addition & 1 deletion internal/generator/generator_test.feature
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Feature: Guess the word
Scenario: <main_player> starts a game
Scenario Outline: <main_player> starts a game
When the <main_player> starts a game at start_date
Then the <main_player> waits for a <oponent_player> to join
Examples:
Expand Down

0 comments on commit 6251e1f

Please sign in to comment.