Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Added better testing of the Context Initializers and TestSuite{}.Run() #301

Merged
merged 1 commit into from
Jun 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions fmt_output_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ func fmtOutputTest(fmtName, testName, featureFilePath string) func(*testing.T) {
s.Step(`^odd (\d+) and even (\d+) number$`, oddEvenStepDef)
}

fmtOutputScenarioInitializer := func(ctx *godog.ScenarioContext) {
ctx.Step(`^(?:a )?failing step`, failingStepDef)
ctx.Step(`^(?:a )?pending step$`, pendingStepDef)
ctx.Step(`^(?:a )?passing step$`, passingStepDef)
ctx.Step(`^odd (\d+) and even (\d+) number$`, oddEvenStepDef)
}

return func(t *testing.T) {
expectOutputPath := strings.Replace(featureFilePath, "features", fmtName, 1)
expectOutputPath = strings.TrimSuffix(expectOutputPath, path.Ext(expectOutputPath))
Expand All @@ -91,6 +98,18 @@ func fmtOutputTest(fmtName, testName, featureFilePath string) func(*testing.T) {
expected := string(expectedOutput)
actual := buf.String()
assert.Equalf(t, expected, actual, "path: %s", expectOutputPath)

buf.Reset()

godog.TestSuite{
Name: fmtName,
ScenarioInitializer: fmtOutputScenarioInitializer,
Options: &opts,
}.Run()

expected = string(expectedOutput)
actual = buf.String()
assert.Equalf(t, expected, actual, "path: %s", expectOutputPath)
}
}

Expand Down
30 changes: 15 additions & 15 deletions formatter-tests/cucumber/scenario_outline
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"name": "passing step",
"line": 13,
"match": {
"location": "fmt_output_test.go:97"
"location": "fmt_output_test.go:116"
},
"result": {
"status": "passed",
Expand All @@ -60,7 +60,7 @@
"name": "passing step",
"line": 13,
"match": {
"location": "fmt_output_test.go:97"
"location": "fmt_output_test.go:116"
},
"result": {
"status": "passed",
Expand All @@ -72,7 +72,7 @@
"name": "odd 1 and even 2 number",
"line": 13,
"match": {
"location": "fmt_output_test.go:99"
"location": "fmt_output_test.go:118"
},
"result": {
"status": "passed",
Expand Down Expand Up @@ -112,7 +112,7 @@
"name": "passing step",
"line": 14,
"match": {
"location": "fmt_output_test.go:97"
"location": "fmt_output_test.go:116"
},
"result": {
"status": "passed",
Expand All @@ -124,7 +124,7 @@
"name": "passing step",
"line": 14,
"match": {
"location": "fmt_output_test.go:97"
"location": "fmt_output_test.go:116"
},
"result": {
"status": "passed",
Expand All @@ -136,7 +136,7 @@
"name": "odd 2 and even 0 number",
"line": 14,
"match": {
"location": "fmt_output_test.go:99"
"location": "fmt_output_test.go:118"
},
"result": {
"status": "failed",
Expand Down Expand Up @@ -177,7 +177,7 @@
"name": "passing step",
"line": 15,
"match": {
"location": "fmt_output_test.go:97"
"location": "fmt_output_test.go:116"
},
"result": {
"status": "passed",
Expand All @@ -189,7 +189,7 @@
"name": "passing step",
"line": 15,
"match": {
"location": "fmt_output_test.go:97"
"location": "fmt_output_test.go:116"
},
"result": {
"status": "passed",
Expand All @@ -201,7 +201,7 @@
"name": "odd 3 and even 11 number",
"line": 15,
"match": {
"location": "fmt_output_test.go:99"
"location": "fmt_output_test.go:118"
},
"result": {
"status": "failed",
Expand Down Expand Up @@ -242,7 +242,7 @@
"name": "passing step",
"line": 20,
"match": {
"location": "fmt_output_test.go:97"
"location": "fmt_output_test.go:116"
},
"result": {
"status": "passed",
Expand All @@ -254,7 +254,7 @@
"name": "passing step",
"line": 20,
"match": {
"location": "fmt_output_test.go:97"
"location": "fmt_output_test.go:116"
},
"result": {
"status": "passed",
Expand All @@ -266,7 +266,7 @@
"name": "odd 1 and even 14 number",
"line": 20,
"match": {
"location": "fmt_output_test.go:99"
"location": "fmt_output_test.go:118"
},
"result": {
"status": "passed",
Expand Down Expand Up @@ -306,7 +306,7 @@
"name": "passing step",
"line": 21,
"match": {
"location": "fmt_output_test.go:97"
"location": "fmt_output_test.go:116"
},
"result": {
"status": "passed",
Expand All @@ -318,7 +318,7 @@
"name": "passing step",
"line": 21,
"match": {
"location": "fmt_output_test.go:97"
"location": "fmt_output_test.go:116"
},
"result": {
"status": "passed",
Expand All @@ -330,7 +330,7 @@
"name": "odd 3 and even 9 number",
"line": 21,
"match": {
"location": "fmt_output_test.go:99"
"location": "fmt_output_test.go:118"
},
"result": {
"status": "failed",
Expand Down
8 changes: 4 additions & 4 deletions formatter-tests/cucumber/scenario_with_background
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"name": "passing step",
"line": 4,
"match": {
"location": "fmt_output_test.go:97"
"location": "fmt_output_test.go:116"
},
"result": {
"status": "passed",
Expand All @@ -32,7 +32,7 @@
"name": "passing step",
"line": 5,
"match": {
"location": "fmt_output_test.go:97"
"location": "fmt_output_test.go:116"
},
"result": {
"status": "passed",
Expand All @@ -44,7 +44,7 @@
"name": "passing step",
"line": 8,
"match": {
"location": "fmt_output_test.go:97"
"location": "fmt_output_test.go:116"
},
"result": {
"status": "passed",
Expand All @@ -56,7 +56,7 @@
"name": "passing step",
"line": 9,
"match": {
"location": "fmt_output_test.go:97"
"location": "fmt_output_test.go:116"
},
"result": {
"status": "passed",
Expand Down
2 changes: 1 addition & 1 deletion formatter-tests/cucumber/single_scenario_with_passing_step
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"name": "a passing step",
"line": 7,
"match": {
"location": "fmt_output_test.go:97"
"location": "fmt_output_test.go:116"
},
"result": {
"status": "passed",
Expand Down
10 changes: 5 additions & 5 deletions formatter-tests/cucumber/some_scenarions_including_failing
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"name": "passing step",
"line": 4,
"match": {
"location": "fmt_output_test.go:97"
"location": "fmt_output_test.go:116"
},
"result": {
"status": "passed",
Expand All @@ -32,7 +32,7 @@
"name": "failing step",
"line": 5,
"match": {
"location": "fmt_output_test.go:113"
"location": "fmt_output_test.go:132"
},
"result": {
"status": "failed",
Expand All @@ -45,7 +45,7 @@
"name": "passing step",
"line": 6,
"match": {
"location": "fmt_output_test.go:97"
"location": "fmt_output_test.go:116"
},
"result": {
"status": "skipped"
Expand Down Expand Up @@ -77,7 +77,7 @@
"name": "passing step",
"line": 10,
"match": {
"location": "fmt_output_test.go:97"
"location": "fmt_output_test.go:116"
},
"result": {
"status": "skipped"
Expand Down Expand Up @@ -109,7 +109,7 @@
"name": "passing step",
"line": 14,
"match": {
"location": "fmt_output_test.go:97"
"location": "fmt_output_test.go:116"
},
"result": {
"status": "skipped"
Expand Down
14 changes: 7 additions & 7 deletions formatter-tests/cucumber/two_scenarios_with_background_fail
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"name": "passing step",
"line": 4,
"match": {
"location": "fmt_output_test.go:97"
"location": "fmt_output_test.go:116"
},
"result": {
"status": "passed",
Expand All @@ -32,7 +32,7 @@
"name": "failing step",
"line": 5,
"match": {
"location": "fmt_output_test.go:113"
"location": "fmt_output_test.go:132"
},
"result": {
"status": "failed",
Expand All @@ -45,7 +45,7 @@
"name": "passing step",
"line": 8,
"match": {
"location": "fmt_output_test.go:97"
"location": "fmt_output_test.go:116"
},
"result": {
"status": "skipped"
Expand All @@ -56,7 +56,7 @@
"name": "passing step",
"line": 9,
"match": {
"location": "fmt_output_test.go:97"
"location": "fmt_output_test.go:116"
},
"result": {
"status": "skipped"
Expand All @@ -77,7 +77,7 @@
"name": "passing step",
"line": 4,
"match": {
"location": "fmt_output_test.go:97"
"location": "fmt_output_test.go:116"
},
"result": {
"status": "passed",
Expand All @@ -89,7 +89,7 @@
"name": "failing step",
"line": 5,
"match": {
"location": "fmt_output_test.go:113"
"location": "fmt_output_test.go:132"
},
"result": {
"status": "failed",
Expand All @@ -102,7 +102,7 @@
"name": "passing step",
"line": 12,
"match": {
"location": "fmt_output_test.go:97"
"location": "fmt_output_test.go:116"
},
"result": {
"status": "skipped"
Expand Down
Loading