-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
887 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
package {{ .PackageName }} | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
{{ define "Background" }} | ||
{{- $Background := . -}} | ||
background := func(t *testing.T) interface{} { | ||
{{- range $Background.Steps }} | ||
// {{ .Keyword }}{{ .Text }} | ||
|
||
{{ end }} | ||
|
||
return nil // TODO: Feel free to modify return value(s). | ||
} | ||
|
||
{{ end }} | ||
|
||
{{ define "Scenario" }} | ||
{{- $Scenario := . -}} | ||
t.Run({{ $Scenario.PluginData.GoValue }}, func({{- /* | ||
t is usualy unused if there are no examples | ||
*/ -}}{{- if and $Scenario.Examples (not $Scenario.PluginData.GoParallel) -}}_{{- else -}}t{{- end -}} *testing.T) { | ||
{{- range $Scenario.Examples }} | ||
{{- if $Scenario.PluginData.GoParallel }} | ||
t.Parallel() | ||
|
||
{{ end -}} | ||
|
||
{{- /* Define test case struct. */ -}} | ||
|
||
type testCase struct { | ||
{{- range .TableHeader.Cells }} | ||
{{ .PluginData.GoName }} {{ .PluginData.GoType }} `field:"{{.Value}}"` | ||
{{- end -}} | ||
} | ||
|
||
testCases := map[string]testCase{ | ||
{{- range .TableBody }} | ||
{{ .PluginData.GoValue }}: { | ||
{{- /* Struct fields start. */ -}} | ||
{{- range $index, $cell := .Cells -}} | ||
{{- if $index -}},{{ end }} {{- $cell.PluginData.GoValue -}} | ||
{{- end -}} | ||
{{- /* Struct fields end. */ -}} | ||
}, | ||
{{- end }} | ||
} | ||
|
||
for name, tc := range testCases { | ||
{{- if $Scenario.PluginData.GoParallel }} | ||
tc := tc | ||
{{ end -}} | ||
|
||
t.Run(name, func(t *testing.T) { | ||
{{- if $Scenario.PluginData.GoParallel }} | ||
t.Parallel() | ||
|
||
{{ end -}} | ||
_ = tc // TODO: Use and remove. | ||
{{- if $Scenario.PluginData.GoHasBackground }} | ||
_ = background(t) | ||
|
||
{{ end -}} | ||
|
||
{{- range $Scenario.Steps }} | ||
// {{ .Keyword }}{{ .Text }} | ||
|
||
{{ end }} | ||
}) | ||
} | ||
{{- else }} | ||
{{- if $Scenario.PluginData.GoParallel }} | ||
t.Parallel() | ||
|
||
{{ end -}} | ||
{{- if $Scenario.PluginData.GoHasBackground }} | ||
_ = background(t) | ||
|
||
{{ end }} | ||
{{- range $Scenario.Steps }} | ||
// {{ .Keyword }}{{ .Text }} | ||
|
||
{{ end -}} | ||
{{ end }} | ||
}) | ||
{{ end }} | ||
|
||
{{ define "Rule" }} | ||
{{ $Rule := . }} | ||
t.Run({{ $Rule.PluginData.GoValue }}, func({{- if $Rule.PluginData.GoParallel -}}t{{- else -}}_{{- end -}} *testing.T) { | ||
{{- if $Rule.PluginData.GoParallel }} | ||
t.Parallel() | ||
|
||
{{ end -}} | ||
{{- range $Rule.Children -}} | ||
|
||
{{- if .Background }} | ||
{{ template "Background" .Background }} | ||
{{- end }} | ||
|
||
{{- if .Scenario }} | ||
{{- template "Scenario" .Scenario -}} | ||
{{- end }} | ||
|
||
{{- end -}} | ||
}) | ||
{{ end }} | ||
|
||
func Test{{ .Feature.PluginData.GoName }}(t *testing.T) { | ||
{{- if .Feature.PluginData.GoParallel }} | ||
t.Parallel() | ||
|
||
{{ end -}} | ||
{{ if .Feature.PluginData.GoComment }} | ||
/* {{ .Feature.PluginData.GoComment }} */ | ||
{{ end }} | ||
|
||
{{- range .Feature.Children }} | ||
|
||
{{ if .Background }} | ||
{{ template "Background" .Background }} | ||
{{- end -}} | ||
|
||
{{ if .Scenario }} | ||
{{ template "Scenario" .Scenario }} | ||
{{- end -}} | ||
|
||
{{ if .Rule }} | ||
{{ template "Rule" .Rule }} | ||
{{- end -}} | ||
|
||
{{- end -}} | ||
} |
57 changes: 57 additions & 0 deletions
57
internal/generator/examples/simple/background.feature_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package examples_test | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestMultipleSiteSupport(t *testing.T) { | ||
/* | ||
Only blog owners can post to a blog, except administrators, | ||
who can post to all blogs. | ||
*/ | ||
|
||
background := func(t *testing.T) interface{} { | ||
// Given a global administrator named "Greg" | ||
|
||
// And a blog named "Greg's anti-tax rants" | ||
|
||
// And a customer named "Dr. Bill" | ||
|
||
// And a blog named "Expensive Therapy" owned by "Dr. Bill" | ||
|
||
return nil // TODO: Feel free to modify return value(s). | ||
} | ||
|
||
t.Run("Dr. Bill posts to his own blog", func(t *testing.T) { | ||
_ = background(t) | ||
|
||
// Given I am logged in as Dr. Bill | ||
|
||
// When I try to post to "Expensive Therapy" | ||
|
||
// Then I should see "Your article was published." | ||
|
||
}) | ||
|
||
t.Run("Dr. Bill tries to post to somebody else's blog, and fails", func(t *testing.T) { | ||
_ = background(t) | ||
|
||
// Given I am logged in as Dr. Bill | ||
|
||
// When I try to post to "Greg's anti-tax rants" | ||
|
||
// Then I should see "Hey! That's not your blog!" | ||
|
||
}) | ||
|
||
t.Run("Greg posts to a client's blog", func(t *testing.T) { | ||
_ = background(t) | ||
|
||
// Given I am logged in as Greg | ||
|
||
// When I try to post to "Expensive Therapy" | ||
|
||
// Then I should see "Your article was published." | ||
|
||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package examples_test | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestTypeDeterminatiopn(t *testing.T) { | ||
|
||
t.Run("All type are determinated", func(_ *testing.T) { | ||
type testCase struct { | ||
Bool bool `field:"<bool>"` | ||
Int int `field:"<int>"` | ||
String string `field:"<string>"` | ||
Flag bool `field:"<flag>"` | ||
Float64 float64 `field:"<float64>"` | ||
} | ||
|
||
testCases := map[string]testCase{ | ||
"true_1_hello_-_1.0": {true, 1, "hello", false, 1.0}, | ||
"false_2_world_+_0.0": {false, 2, "world", true, 0.0}, | ||
} | ||
|
||
for name, tc := range testCases { | ||
t.Run(name, func(t *testing.T) { | ||
_ = tc // TODO: Use and remove. | ||
// When generator comleted | ||
|
||
// Then correct types are shown | ||
|
||
}) | ||
} | ||
}) | ||
} |
48 changes: 48 additions & 0 deletions
48
internal/generator/examples/simple/complex.feature_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package examples_test | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestNestedBackground(t *testing.T) { | ||
|
||
background := func(t *testing.T) interface{} { | ||
// Given a global administrator named "Greg" | ||
|
||
// And a blog named "Greg's anti-tax rants" | ||
|
||
// And a customer named "Dr. Bill" | ||
|
||
// And a blog named "Expensive Therapy" owned by "Dr. Bill" | ||
|
||
return nil // TODO: Feel free to modify return value(s). | ||
} | ||
|
||
t.Run("Dr. Bill posts to his own blog", func(t *testing.T) { | ||
_ = background(t) | ||
|
||
// Given I am logged in as Dr. Bill | ||
|
||
// When I try to post to "Expensive Therapy" | ||
|
||
// Then I should see "Your article was published." | ||
|
||
}) | ||
|
||
t.Run("There can be only One", func(_ *testing.T) { | ||
background := func(t *testing.T) interface{} { | ||
// Given I have overdue tasks | ||
|
||
return nil // TODO: Feel free to modify return value(s). | ||
} | ||
|
||
t.Run("Only One -- One alive", func(t *testing.T) { | ||
_ = background(t) | ||
|
||
// Given there is only 1 ninja alive | ||
|
||
// Then he (or she) will live forever ;-) | ||
|
||
}) | ||
}) | ||
} |
24 changes: 24 additions & 0 deletions
24
internal/generator/examples/simple/issue_26.feature_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package examples_test | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestIssueExample(t *testing.T) { | ||
|
||
t.Run("Just a hello world", func(_ *testing.T) { | ||
type testCase struct { | ||
Name string `field:"<name>"` | ||
} | ||
|
||
testCases := map[string]testCase{ | ||
"hello_world": {"hello world"}, | ||
} | ||
|
||
for name, tc := range testCases { | ||
t.Run(name, func(t *testing.T) { | ||
_ = tc // TODO: Use and remove. | ||
}) | ||
} | ||
}) | ||
} |
20 changes: 20 additions & 0 deletions
20
internal/generator/examples/simple/issue_27_multi.feature_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package examples_test | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestExampleIssue27Multi(t *testing.T) { | ||
/* | ||
Details: | ||
- example 1 | ||
- example 2 | ||
- example 3 | ||
- example 3.1 | ||
- example 3.2 | ||
*/ | ||
|
||
t.Run("Multi-line comment with indents", func(t *testing.T) { | ||
}) | ||
} |
Oops, something went wrong.