diff --git a/run_cucumber_test.go b/fixtures/cucumber_output.json similarity index 99% rename from run_cucumber_test.go rename to fixtures/cucumber_output.json index a0d14df..05a74f4 100644 --- a/run_cucumber_test.go +++ b/fixtures/cucumber_output.json @@ -1,25 +1,4 @@ -package godog - -import ( - "fmt" - "testing" -) - -func TestSucceedWithCucumber(t *testing.T) { - const format = "cucumber" - - // Will test concurrency setting 0 and 1, which means no concurrency. - for concurrency := range make([]int, 2) { - t.Run( - fmt.Sprintf("%s_concurrency_%d", format, concurrency), - func(t *testing.T) { - testSucceedRun(t, format, concurrency, expectedOutputCucumber) - }, - ) - } -} - -const expectedOutputCucumber = `[ +[ { "uri": "features/background.feature", "id": "run-background", @@ -4023,7 +4002,7 @@ const expectedOutputCucumber = `[ "name": "the undefined step snippets should be:", "line": 21, "doc_string": { - "value": "func iSendRequestTo(arg1, arg2 string) error {\n return godog.ErrPending\n}\n\nfunc theResponseCodeShouldBe(arg1 int) error {\n return godog.ErrPending\n}\n\nfunc FeatureContext(s *godog.Suite) {\n s.Step(` + "`" + `^I send \"([^\"]*)\" request to \"([^\"]*)\"$` + "`" + `, iSendRequestTo)\n s.Step(` + "`" + `^the response code should be (\\d+)$` + "`" + `, theResponseCodeShouldBe)\n}", + "value": "func iSendRequestTo(arg1, arg2 string) error {\n return godog.ErrPending\n}\n\nfunc theResponseCodeShouldBe(arg1 int) error {\n return godog.ErrPending\n}\n\nfunc FeatureContext(s *godog.Suite) {\n s.Step(`^I send \"([^\"]*)\" request to \"([^\"]*)\"$`, iSendRequestTo)\n s.Step(`^the response code should be (\\d+)$`, theResponseCodeShouldBe)\n}", "content_type": "", "line": 22 }, @@ -4079,7 +4058,7 @@ const expectedOutputCucumber = `[ "name": "the undefined step snippets should be:", "line": 49, "doc_string": { - "value": "func iSendRequestToWith(arg1, arg2 string, arg3 *gherkin.DataTable) error {\n return godog.ErrPending\n}\n\nfunc theResponseCodeShouldBeAndHeaderShouldBe(arg1 int, arg2, arg3 string) error {\n return godog.ErrPending\n}\n\nfunc FeatureContext(s *godog.Suite) {\n s.Step(` + "`" + `^I send \"([^\"]*)\" request to \"([^\"]*)\" with:$` + "`" + `, iSendRequestToWith)\n s.Step(` + "`" + `^the response code should be (\\d+) and header \"([^\"]*)\" should be \"([^\"]*)\"$` + "`" + `, theResponseCodeShouldBeAndHeaderShouldBe)\n}", + "value": "func iSendRequestToWith(arg1, arg2 string, arg3 *gherkin.DataTable) error {\n return godog.ErrPending\n}\n\nfunc theResponseCodeShouldBeAndHeaderShouldBe(arg1 int, arg2, arg3 string) error {\n return godog.ErrPending\n}\n\nfunc FeatureContext(s *godog.Suite) {\n s.Step(`^I send \"([^\"]*)\" request to \"([^\"]*)\" with:$`, iSendRequestToWith)\n s.Step(`^the response code should be (\\d+) and header \"([^\"]*)\" should be \"([^\"]*)\"$`, theResponseCodeShouldBeAndHeaderShouldBe)\n}", "content_type": "", "line": 50 }, @@ -4152,7 +4131,7 @@ const expectedOutputCucumber = `[ "name": "the undefined step snippets should be:", "line": 80, "doc_string": { - "value": "func iPullFromGithubcom() error {\n return godog.ErrPending\n}\n\nfunc theProjectShouldBeThere() error {\n return godog.ErrPending\n}\n\nfunc FeatureContext(s *godog.Suite) {\n s.Step(` + "`" + `^I pull from github\\.com$` + "`" + `, iPullFromGithubcom)\n s.Step(` + "`" + `^the project should be there$` + "`" + `, theProjectShouldBeThere)\n}", + "value": "func iPullFromGithubcom() error {\n return godog.ErrPending\n}\n\nfunc theProjectShouldBeThere() error {\n return godog.ErrPending\n}\n\nfunc FeatureContext(s *godog.Suite) {\n s.Step(`^I pull from github\\.com$`, iPullFromGithubcom)\n s.Step(`^the project should be there$`, theProjectShouldBeThere)\n}", "content_type": "", "line": 81 }, @@ -4208,7 +4187,7 @@ const expectedOutputCucumber = `[ "name": "the undefined step snippets should be:", "line": 106, "doc_string": { - "value": "func thereIsAWhichCosts(arg1 string, arg2 int) error {\n return godog.ErrPending\n}\n\nfunc iAddTheToTheBasket(arg1 string) error {\n return godog.ErrPending\n}\n\nfunc FeatureContext(s *godog.Suite) {\n s.Step(` + "`" + `^there is a \"([^\"]*)\", which costs £(\\d+)$` + "`" + `, thereIsAWhichCosts)\n s.Step(` + "`" + `^I add the \"([^\"]*)\" to the basket$` + "`" + `, iAddTheToTheBasket)\n}", + "value": "func thereIsAWhichCosts(arg1 string, arg2 int) error {\n return godog.ErrPending\n}\n\nfunc iAddTheToTheBasket(arg1 string) error {\n return godog.ErrPending\n}\n\nfunc FeatureContext(s *godog.Suite) {\n s.Step(`^there is a \"([^\"]*)\", which costs £(\\d+)$`, thereIsAWhichCosts)\n s.Step(`^I add the \"([^\"]*)\" to the basket$`, iAddTheToTheBasket)\n}", "content_type": "", "line": 107 }, @@ -4264,7 +4243,7 @@ const expectedOutputCucumber = `[ "name": "the undefined step snippets should be:", "line": 132, "doc_string": { - "value": "func whichCosts(arg1 string, arg2 int) error {\n return godog.ErrPending\n}\n\nfunc godogs(arg1 int) error {\n return godog.ErrPending\n}\n\nfunc FeatureContext(s *godog.Suite) {\n s.Step(` + "`" + `^\"([^\"]*)\", which costs £(\\d+)$` + "`" + `, whichCosts)\n s.Step(` + "`" + `^(\\d+) godogs$` + "`" + `, godogs)\n}", + "value": "func whichCosts(arg1 string, arg2 int) error {\n return godog.ErrPending\n}\n\nfunc godogs(arg1 int) error {\n return godog.ErrPending\n}\n\nfunc FeatureContext(s *godog.Suite) {\n s.Step(`^\"([^\"]*)\", which costs £(\\d+)$`, whichCosts)\n s.Step(`^(\\d+) godogs$`, godogs)\n}", "content_type": "", "line": 133 }, @@ -4610,4 +4589,4 @@ const expectedOutputCucumber = `[ } ] } -]` +] \ No newline at end of file diff --git a/run_junit_test.go b/fixtures/junit_output.xml similarity index 94% rename from run_junit_test.go rename to fixtures/junit_output.xml index 1485c31..2bd324f 100644 --- a/run_junit_test.go +++ b/fixtures/junit_output.xml @@ -1,25 +1,4 @@ -package godog - -import ( - "fmt" - "testing" -) - -func TestSucceedWithJUnit(t *testing.T) { - const format = "junit" - - // Will test concurrency setting 0, 1, 2 and 3. - for concurrency := range make([]int, 4) { - t.Run( - fmt.Sprintf("%s_concurrency_%d", format, concurrency), - func(t *testing.T) { - testSucceedRun(t, format, concurrency, expectedOutputJUnit) - }, - ) - } -} - -const expectedOutputJUnit = ` + @@ -103,4 +82,4 @@ const expectedOutputJUnit = ` -` + \ No newline at end of file diff --git a/fixtures/progress_output.txt b/fixtures/progress_output.txt new file mode 100644 index 0000000..acecbd9 --- /dev/null +++ b/fixtures/progress_output.txt @@ -0,0 +1,9 @@ +...................................................................... 70 +...................................................................... 140 +...................................................................... 210 +....................................... 249 + + +60 scenarios (60 passed) +249 steps (249 passed) +0s \ No newline at end of file diff --git a/run_progress_test.go b/run_progress_test.go deleted file mode 100644 index 1e93898..0000000 --- a/run_progress_test.go +++ /dev/null @@ -1,30 +0,0 @@ -package godog - -import ( - "fmt" - "testing" -) - -func TestSucceedRun(t *testing.T) { - const format = "progress" - - // Will test concurrency setting 0, 1, 2 and 3. - for concurrency := range make([]int, 4) { - t.Run( - fmt.Sprintf("%s_concurrency_%d", format, concurrency), - func(t *testing.T) { - testSucceedRun(t, format, concurrency, expectedOutputProgress) - }, - ) - } -} - -const expectedOutputProgress = `...................................................................... 70 -...................................................................... 140 -...................................................................... 210 -....................................... 249 - - -60 scenarios (60 passed) -249 steps (249 passed) -0s` diff --git a/run_test.go b/run_test.go index 686d613..e858a9c 100644 --- a/run_test.go +++ b/run_test.go @@ -276,6 +276,36 @@ func TestFeatureFilePathParser(t *testing.T) { } } +type succeedRunTestCase struct { + format string // formatter to use + concurrency int // concurrency option range to test + filename string // expected output file +} + +func TestSucceedRun(t *testing.T) { + testCases := []succeedRunTestCase{ + {format: "progress", concurrency: 4, filename: "fixtures/progress_output.txt"}, + {format: "junit", concurrency: 4, filename: "fixtures/junit_output.xml"}, + {format: "cucumber", concurrency: 2, filename: "fixtures/cucumber_output.json"}, + } + + for _, tc := range testCases { + expectedOutput, err := ioutil.ReadFile(tc.filename) + if err != nil { + t.Fatal(err) + } + + for concurrency := range make([]int, tc.concurrency) { + t.Run( + fmt.Sprintf("%s/concurrency/%d", tc.format, concurrency), + func(t *testing.T) { + testSucceedRun(t, tc.format, concurrency, string(expectedOutput)) + }, + ) + } + } +} + func testSucceedRun(t *testing.T, format string, concurrency int, expectedOutput string) { output := new(bytes.Buffer)