From 3ca715665017ba1bdd0cba62887a15870c894d4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20L=C3=B6nnblad?= Date: Fri, 22 May 2020 11:57:00 +0200 Subject: [PATCH] Moved the fmt tests to a godog_test pkg and restructured the fmt output tests --- .circleci/config.yml | 2 +- fmt.go | 5 +- color_tag_test.go => fmt_color_tag_test.go | 2 +- fmt_junit_test.go | 176 ------------------ fmt_output_test.go | 113 +++++++++++ fmt_progress_test.go | 140 +------------- fmt_test.go | 72 +++++-- formatter-tests/cucumber/scenario_outline | 30 +-- .../cucumber/scenario_with_background | 8 +- .../single_scenario_with_passing_step | 2 +- .../some_scenarions_including_failing | 10 +- .../two_scenarios_with_background_fail | 14 +- formatter-tests/events/scenario_outline | 30 +-- .../events/scenario_with_background | 8 +- .../events/single_scenario_with_passing_step | 2 +- .../events/some_scenarions_including_failing | 12 +- .../events/two_scenarios_with_background_fail | 14 +- formatter-tests/pretty/scenario_outline | 6 +- .../pretty/scenario_with_background | 8 +- .../pretty/single_scenario_with_passing_step | 2 +- .../pretty/some_scenarions_including_failing | 12 +- .../pretty/two_scenarios_with_background_fail | 10 +- formatters_print_test.go | 79 -------- 23 files changed, 261 insertions(+), 496 deletions(-) rename color_tag_test.go => fmt_color_tag_test.go (99%) delete mode 100644 fmt_junit_test.go create mode 100644 fmt_output_test.go delete mode 100644 formatters_print_test.go diff --git a/.circleci/config.yml b/.circleci/config.yml index 2bd5cf0..f6e9524 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -37,6 +37,7 @@ commands: go_test: description: "Run go test" steps: + - run: sed -i 's#github.com/cucumber/godog_test#_test#g' formatter-tests/*/* - run: go test -v -race -coverprofile=coverage.txt -covermode=atomic godog: description: "Run godog" @@ -67,7 +68,6 @@ commands: - part1 - part2 - jobs: go1_12: working_directory: /go/src/github.com/cucumber/godog diff --git a/fmt.go b/fmt.go index 64793b8..af4e796 100644 --- a/fmt.go +++ b/fmt.go @@ -19,8 +19,8 @@ import ( type registeredFormatter struct { name string - fmt FormatterFunc description string + fmt FormatterFunc } var formatters []*registeredFormatter @@ -34,6 +34,7 @@ func FindFmt(name string) FormatterFunc { return el.fmt } } + return nil } @@ -54,9 +55,11 @@ func Format(name, description string, f FormatterFunc) { // and description as value func AvailableFormatters() map[string]string { fmts := make(map[string]string, len(formatters)) + for _, f := range formatters { fmts[f.name] = f.description } + return fmts } diff --git a/color_tag_test.go b/fmt_color_tag_test.go similarity index 99% rename from color_tag_test.go rename to fmt_color_tag_test.go index 5841c36..6a2a19a 100644 --- a/color_tag_test.go +++ b/fmt_color_tag_test.go @@ -1,4 +1,4 @@ -package godog +package godog_test import ( "bytes" diff --git a/fmt_junit_test.go b/fmt_junit_test.go deleted file mode 100644 index 1568893..0000000 --- a/fmt_junit_test.go +++ /dev/null @@ -1,176 +0,0 @@ -package godog - -import ( - "bytes" - "encoding/xml" - "fmt" - "io" - "strings" - "testing" - - "github.com/cucumber/gherkin-go/v11" - "github.com/cucumber/messages-go/v10" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - "github.com/cucumber/godog/colors" -) - -var sampleGherkinFeature = ` -Feature: junit formatter - - Background: - Given passing - - Scenario: passing scenario - Then passing - - Scenario: failing scenario - When failing - Then passing - - Scenario: pending scenario - When pending - Then passing - - Scenario: undefined scenario - When undefined - Then next undefined - - Scenario Outline: outline - Given - When - - Examples: - | one | two | - | passing | passing | - | passing | failing | - | passing | pending | - - Examples: - | one | two | - | passing | undefined | -` - -func TestJUnitFormatterOutput(t *testing.T) { - const path = "any.feature" - - gd, err := gherkin.ParseGherkinDocument(strings.NewReader(sampleGherkinFeature), (&messages.Incrementing{}).NewId) - require.NoError(t, err) - - pickles := gherkin.Pickles(*gd, path, (&messages.Incrementing{}).NewId) - - var buf bytes.Buffer - w := colors.Uncolored(&buf) - s := &Suite{ - fmt: junitFunc("junit", w), - features: []*feature{{ - GherkinDocument: gd, - pickles: pickles, - Path: path, - Content: []byte(sampleGherkinFeature), - }}, - } - - s.Step(`^passing$`, func() error { return nil }) - s.Step(`^failing$`, func() error { return fmt.Errorf("errored") }) - s.Step(`^pending$`, func() error { return ErrPending }) - - const zeroDuration = "0" - expected := junitPackageSuite{ - Name: "junit", - Tests: 8, - Skipped: 0, - Failures: 2, - Errors: 4, - Time: zeroDuration, - TestSuites: []*junitTestSuite{{ - Name: "junit formatter", - Tests: 8, - Skipped: 0, - Failures: 2, - Errors: 4, - Time: zeroDuration, - TestCases: []*junitTestCase{ - { - Name: "passing scenario", - Status: "passed", - Time: zeroDuration, - }, - { - Name: "failing scenario", - Status: "failed", - Time: zeroDuration, - Failure: &junitFailure{ - Message: "Step failing: errored", - }, - Error: []*junitError{ - {Message: "Step passing", Type: "skipped"}, - }, - }, - { - Name: "pending scenario", - Status: "pending", - Time: zeroDuration, - Error: []*junitError{ - {Message: "Step pending: TODO: write pending definition", Type: "pending"}, - {Message: "Step passing", Type: "skipped"}, - }, - }, - { - Name: "undefined scenario", - Status: "undefined", - Time: zeroDuration, - Error: []*junitError{ - {Message: "Step undefined", Type: "undefined"}, - {Message: "Step next undefined", Type: "undefined"}, - }, - }, - { - Name: "outline #1", - Status: "passed", - Time: zeroDuration, - }, - { - Name: "outline #2", - Status: "failed", - Time: zeroDuration, - Failure: &junitFailure{ - Message: "Step failing: errored", - }, - }, - { - Name: "outline #3", - Status: "pending", - Time: zeroDuration, - Error: []*junitError{ - {Message: "Step pending: TODO: write pending definition", Type: "pending"}, - }, - }, - { - Name: "outline #4", - Status: "undefined", - Time: zeroDuration, - Error: []*junitError{ - {Message: "Step undefined", Type: "undefined"}, - }, - }, - }, - }}, - } - - s.fmt.TestRunStarted() - s.run() - s.fmt.Summary() - - var exp bytes.Buffer - _, err = io.WriteString(&exp, xml.Header) - require.NoError(t, err) - - enc := xml.NewEncoder(&exp) - enc.Indent("", " ") - err = enc.Encode(expected) - require.NoError(t, err) - - assert.Equal(t, exp.String(), buf.String()) -} diff --git a/fmt_output_test.go b/fmt_output_test.go new file mode 100644 index 0000000..c9f53fd --- /dev/null +++ b/fmt_output_test.go @@ -0,0 +1,113 @@ +package godog_test + +import ( + "bytes" + "fmt" + "io/ioutil" + "os" + "path" + "path/filepath" + "strings" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/cucumber/godog" +) + +const fmtOutputTestsFeatureDir = "formatter-tests/features" + +func Test_FmtOutput(t *testing.T) { + pkg := os.Getenv("GODOG_TESTED_PACKAGE") + os.Setenv("GODOG_TESTED_PACKAGE", "github.com/cucumber/godog") + + featureFiles, err := listFmtOutputTestsFeatureFiles() + require.Nil(t, err) + + formatters := []string{"cucumber", "events", "junit", "pretty", "progress"} + + for _, fmtName := range formatters { + for _, featureFile := range featureFiles { + testName := fmt.Sprintf("%s/%s", fmtName, featureFile) + featureFilePath := fmt.Sprintf("%s/%s", fmtOutputTestsFeatureDir, featureFile) + t.Run(testName, fmtOutputTest(fmtName, testName, featureFilePath)) + } + } + + os.Setenv("GODOG_TESTED_PACKAGE", pkg) +} + +func listFmtOutputTestsFeatureFiles() (featureFiles []string, err error) { + err = filepath.Walk(fmtOutputTestsFeatureDir, func(path string, info os.FileInfo, err error) error { + if err != nil { + return err + } + + if !info.IsDir() { + featureFiles = append(featureFiles, info.Name()) + return nil + } + + if info.Name() == "features" { + return nil + } + + return filepath.SkipDir + }) + + return +} + +func fmtOutputTest(fmtName, testName, featureFilePath string) func(*testing.T) { + fmtOutputSuiteInitializer := func(s *godog.Suite) { + s.Step(`^(?:a )?failing step`, failingStepDef) + s.Step(`^(?:a )?pending step$`, pendingStepDef) + s.Step(`^(?:a )?passing step$`, passingStepDef) + s.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)) + if _, err := os.Stat(expectOutputPath); err != nil { + t.Skipf("Couldn't find expected output file %q", expectOutputPath) + } + + expectedOutput, err := ioutil.ReadFile(expectOutputPath) + require.NoError(t, err) + + var buf bytes.Buffer + out := &tagColorWriter{w: &buf} + + opts := godog.Options{ + Format: fmtName, + Paths: []string{featureFilePath}, + Output: out, + } + + godog.RunWithOptions(fmtName, fmtOutputSuiteInitializer, opts) + + expected := string(expectedOutput) + actual := buf.String() + assert.Equalf(t, expected, actual, "path: %s", expectOutputPath) + } +} + +func passingStepDef() error { return nil } + +func oddEvenStepDef(odd, even int) error { return oddOrEven(odd, even) } + +func oddOrEven(odd, even int) error { + if odd%2 == 0 { + return fmt.Errorf("%d is not odd", odd) + } + if even%2 != 0 { + return fmt.Errorf("%d is not even", even) + } + return nil +} + +func pendingStepDef() error { return godog.ErrPending } + +func failingStepDef() error { return fmt.Errorf("step failed") } diff --git a/fmt_progress_test.go b/fmt_progress_test.go index 690d7a7..a673f54 100644 --- a/fmt_progress_test.go +++ b/fmt_progress_test.go @@ -2,7 +2,6 @@ package godog import ( "bytes" - "fmt" "strings" "testing" @@ -22,73 +21,6 @@ Feature: basic Then two ` -func TestProgressFormatterOutput(t *testing.T) { - const path = "any.feature" - - gd, err := gherkin.ParseGherkinDocument(strings.NewReader(sampleGherkinFeature), (&messages.Incrementing{}).NewId) - require.NoError(t, err) - - pickles := gherkin.Pickles(*gd, path, (&messages.Incrementing{}).NewId) - - var buf bytes.Buffer - w := colors.Uncolored(&buf) - r := runner{ - fmt: progressFunc("progress", w), - features: []*feature{{ - GherkinDocument: gd, - pickles: pickles, - Path: path, - Content: []byte(sampleGherkinFeature), - }}, - initializer: func(s *Suite) { - s.Step(`^passing$`, func() error { return nil }) - s.Step(`^failing$`, func() error { return fmt.Errorf("errored") }) - s.Step(`^pending$`, func() error { return ErrPending }) - }, - } - - expected := `...F-.P-.UU.....F..P..U 23 - - ---- Failed steps: - - Scenario: failing scenario # any.feature:10 - When failing # any.feature:11 - Error: errored - - Scenario Outline: outline # any.feature:22 - When failing # any.feature:24 - Error: errored - - -8 scenarios (2 passed, 2 failed, 2 pending, 2 undefined) -23 steps (14 passed, 2 failed, 2 pending, 3 undefined, 2 skipped) -0s - -You can implement step definitions for undefined steps with these snippets: - -func nextUndefined() error { - return godog.ErrPending -} - -func undefined() error { - return godog.ErrPending -} - -func FeatureContext(s *godog.Suite) { - s.Step(` + "`^next undefined$`" + `, nextUndefined) - s.Step(` + "`^undefined$`" + `, undefined) -} - -` - - failed := r.concurrent(1, func() Formatter { return progressFunc("progress", w) }) - require.True(t, failed) - - actual := buf.String() - assert.Equal(t, expected, actual) -} - func TestProgressFormatterWhenStepPanics(t *testing.T) { const path = "any.feature" @@ -112,77 +44,7 @@ func TestProgressFormatterWhenStepPanics(t *testing.T) { require.True(t, failed) actual := buf.String() - assert.Contains(t, actual, "godog/fmt_progress_test.go:107") -} - -func TestProgressFormatterWithPassingMultisteps(t *testing.T) { - const path = "any.feature" - - gd, err := gherkin.ParseGherkinDocument(strings.NewReader(basicGherkinFeature), (&messages.Incrementing{}).NewId) - require.NoError(t, err) - - pickles := gherkin.Pickles(*gd, path, (&messages.Incrementing{}).NewId) - - var buf bytes.Buffer - w := colors.Uncolored(&buf) - r := runner{ - fmt: progressFunc("progress", w), - features: []*feature{{GherkinDocument: gd, pickles: pickles}}, - initializer: func(s *Suite) { - s.Step(`^sub1$`, func() error { return nil }) - s.Step(`^sub-sub$`, func() error { return nil }) - s.Step(`^sub2$`, func() Steps { return Steps{"sub-sub", "sub1", "one"} }) - s.Step(`^one$`, func() error { return nil }) - s.Step(`^two$`, func() Steps { return Steps{"sub1", "sub2"} }) - }, - } - - failed := r.concurrent(1, func() Formatter { return progressFunc("progress", w) }) - require.False(t, failed) -} - -func TestProgressFormatterWithFailingMultisteps(t *testing.T) { - const path = "some.feature" - - gd, err := gherkin.ParseGherkinDocument(strings.NewReader(basicGherkinFeature), (&messages.Incrementing{}).NewId) - require.NoError(t, err) - - pickles := gherkin.Pickles(*gd, path, (&messages.Incrementing{}).NewId) - - var buf bytes.Buffer - w := colors.Uncolored(&buf) - r := runner{ - fmt: progressFunc("progress", w), - features: []*feature{{GherkinDocument: gd, pickles: pickles, Path: path}}, - initializer: func(s *Suite) { - s.Step(`^sub1$`, func() error { return nil }) - s.Step(`^sub-sub$`, func() error { return fmt.Errorf("errored") }) - s.Step(`^sub2$`, func() Steps { return Steps{"sub-sub", "sub1", "one"} }) - s.Step(`^one$`, func() error { return nil }) - s.Step(`^two$`, func() Steps { return Steps{"sub1", "sub2"} }) - }, - } - - failed := r.concurrent(1, func() Formatter { return progressFunc("progress", w) }) - require.True(t, failed) - - expected := `.F 2 - - ---- Failed steps: - - Scenario: passing scenario # some.feature:4 - Then two # some.feature:6 - Error: sub2: sub-sub: errored - - -1 scenarios (1 failed) -2 steps (1 passed, 1 failed) -0s -` - - actual := buf.String() - assert.Equal(t, expected, actual) + assert.Contains(t, actual, "godog/fmt_progress_test.go:39") } func TestProgressFormatterWithPanicInMultistep(t *testing.T) { diff --git a/fmt_test.go b/fmt_test.go index 9bd4af1..695da88 100644 --- a/fmt_test.go +++ b/fmt_test.go @@ -1,25 +1,67 @@ -package godog +package godog_test -import "testing" +import ( + "io" + "testing" -func TestShouldFindFormatter(t *testing.T) { + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/cucumber/godog" +) + +func Test_FindFmt(t *testing.T) { cases := map[string]bool{ - "progress": true, // true means should be available - "unknown": false, - "junit": true, "cucumber": true, - "pretty": true, "custom": true, // is available for test purposes only + "events": true, + "junit": true, + "pretty": true, + "progress": true, + "unknown": false, "undef": false, } - for name, shouldFind := range cases { - actual := FindFmt(name) - if actual == nil && shouldFind { - t.Fatalf("expected %s formatter should be available", name) - } - if actual != nil && !shouldFind { - t.Fatalf("expected %s formatter should not be available", name) - } + for name, expected := range cases { + t.Run( + name, + func(t *testing.T) { + actual := godog.FindFmt(name) + + if expected { + assert.NotNilf(t, actual, "expected %s formatter should be available", name) + } else { + assert.Nilf(t, actual, "expected %s formatter should be available", name) + } + }, + ) } } + +func Test_AvailableFormatters(t *testing.T) { + expected := map[string]string{ + "cucumber": "Produces cucumber JSON format output.", + "custom": "custom format description", // is available for test purposes only + "events": "Produces JSON event stream, based on spec: 0.1.0.", + "junit": "Prints junit compatible xml to stdout", + "pretty": "Prints every feature with runtime statuses.", + "progress": "Prints a character per step.", + } + + actual := godog.AvailableFormatters() + assert.Equal(t, expected, actual) +} + +func Test_Format(t *testing.T) { + actual := godog.FindFmt("Test_Format") + require.Nil(t, actual) + + godog.Format("Test_Format", "...", testFormatterFunc) + actual = godog.FindFmt("Test_Format") + + assert.NotNil(t, actual) +} + +func testFormatterFunc(suiteName string, out io.Writer) godog.Formatter { + return nil +} diff --git a/formatter-tests/cucumber/scenario_outline b/formatter-tests/cucumber/scenario_outline index 4ed44a8..54233b4 100644 --- a/formatter-tests/cucumber/scenario_outline +++ b/formatter-tests/cucumber/scenario_outline @@ -48,7 +48,7 @@ "name": "passing step", "line": 13, "match": { - "location": "formatters_print_test.go:63" + "location": "fmt_output_test.go:97" }, "result": { "status": "passed", @@ -60,7 +60,7 @@ "name": "passing step", "line": 13, "match": { - "location": "formatters_print_test.go:63" + "location": "fmt_output_test.go:97" }, "result": { "status": "passed", @@ -72,7 +72,7 @@ "name": "odd 1 and even 2 number", "line": 13, "match": { - "location": "formatters_print_test.go:65" + "location": "fmt_output_test.go:99" }, "result": { "status": "passed", @@ -112,7 +112,7 @@ "name": "passing step", "line": 14, "match": { - "location": "formatters_print_test.go:63" + "location": "fmt_output_test.go:97" }, "result": { "status": "passed", @@ -124,7 +124,7 @@ "name": "passing step", "line": 14, "match": { - "location": "formatters_print_test.go:63" + "location": "fmt_output_test.go:97" }, "result": { "status": "passed", @@ -136,7 +136,7 @@ "name": "odd 2 and even 0 number", "line": 14, "match": { - "location": "formatters_print_test.go:65" + "location": "fmt_output_test.go:99" }, "result": { "status": "failed", @@ -177,7 +177,7 @@ "name": "passing step", "line": 15, "match": { - "location": "formatters_print_test.go:63" + "location": "fmt_output_test.go:97" }, "result": { "status": "passed", @@ -189,7 +189,7 @@ "name": "passing step", "line": 15, "match": { - "location": "formatters_print_test.go:63" + "location": "fmt_output_test.go:97" }, "result": { "status": "passed", @@ -201,7 +201,7 @@ "name": "odd 3 and even 11 number", "line": 15, "match": { - "location": "formatters_print_test.go:65" + "location": "fmt_output_test.go:99" }, "result": { "status": "failed", @@ -242,7 +242,7 @@ "name": "passing step", "line": 20, "match": { - "location": "formatters_print_test.go:63" + "location": "fmt_output_test.go:97" }, "result": { "status": "passed", @@ -254,7 +254,7 @@ "name": "passing step", "line": 20, "match": { - "location": "formatters_print_test.go:63" + "location": "fmt_output_test.go:97" }, "result": { "status": "passed", @@ -266,7 +266,7 @@ "name": "odd 1 and even 14 number", "line": 20, "match": { - "location": "formatters_print_test.go:65" + "location": "fmt_output_test.go:99" }, "result": { "status": "passed", @@ -306,7 +306,7 @@ "name": "passing step", "line": 21, "match": { - "location": "formatters_print_test.go:63" + "location": "fmt_output_test.go:97" }, "result": { "status": "passed", @@ -318,7 +318,7 @@ "name": "passing step", "line": 21, "match": { - "location": "formatters_print_test.go:63" + "location": "fmt_output_test.go:97" }, "result": { "status": "passed", @@ -330,7 +330,7 @@ "name": "odd 3 and even 9 number", "line": 21, "match": { - "location": "formatters_print_test.go:65" + "location": "fmt_output_test.go:99" }, "result": { "status": "failed", diff --git a/formatter-tests/cucumber/scenario_with_background b/formatter-tests/cucumber/scenario_with_background index ca7044f..3fc277e 100644 --- a/formatter-tests/cucumber/scenario_with_background +++ b/formatter-tests/cucumber/scenario_with_background @@ -20,7 +20,7 @@ "name": "passing step", "line": 4, "match": { - "location": "formatters_print_test.go:63" + "location": "fmt_output_test.go:97" }, "result": { "status": "passed", @@ -32,7 +32,7 @@ "name": "passing step", "line": 5, "match": { - "location": "formatters_print_test.go:63" + "location": "fmt_output_test.go:97" }, "result": { "status": "passed", @@ -44,7 +44,7 @@ "name": "passing step", "line": 8, "match": { - "location": "formatters_print_test.go:63" + "location": "fmt_output_test.go:97" }, "result": { "status": "passed", @@ -56,7 +56,7 @@ "name": "passing step", "line": 9, "match": { - "location": "formatters_print_test.go:63" + "location": "fmt_output_test.go:97" }, "result": { "status": "passed", diff --git a/formatter-tests/cucumber/single_scenario_with_passing_step b/formatter-tests/cucumber/single_scenario_with_passing_step index 7580080..78f527f 100644 --- a/formatter-tests/cucumber/single_scenario_with_passing_step +++ b/formatter-tests/cucumber/single_scenario_with_passing_step @@ -20,7 +20,7 @@ "name": "a passing step", "line": 7, "match": { - "location": "formatters_print_test.go:63" + "location": "fmt_output_test.go:97" }, "result": { "status": "passed", diff --git a/formatter-tests/cucumber/some_scenarions_including_failing b/formatter-tests/cucumber/some_scenarions_including_failing index 521d6c2..3a5e4c7 100644 --- a/formatter-tests/cucumber/some_scenarions_including_failing +++ b/formatter-tests/cucumber/some_scenarions_including_failing @@ -20,7 +20,7 @@ "name": "passing step", "line": 4, "match": { - "location": "formatters_print_test.go:63" + "location": "fmt_output_test.go:97" }, "result": { "status": "passed", @@ -32,7 +32,7 @@ "name": "failing step", "line": 5, "match": { - "location": "formatters_print_test.go:79" + "location": "fmt_output_test.go:113" }, "result": { "status": "failed", @@ -45,7 +45,7 @@ "name": "passing step", "line": 6, "match": { - "location": "formatters_print_test.go:63" + "location": "fmt_output_test.go:97" }, "result": { "status": "skipped" @@ -77,7 +77,7 @@ "name": "passing step", "line": 10, "match": { - "location": "formatters_print_test.go:63" + "location": "fmt_output_test.go:97" }, "result": { "status": "skipped" @@ -109,7 +109,7 @@ "name": "passing step", "line": 14, "match": { - "location": "formatters_print_test.go:63" + "location": "fmt_output_test.go:97" }, "result": { "status": "skipped" diff --git a/formatter-tests/cucumber/two_scenarios_with_background_fail b/formatter-tests/cucumber/two_scenarios_with_background_fail index 203449c..1605b8e 100644 --- a/formatter-tests/cucumber/two_scenarios_with_background_fail +++ b/formatter-tests/cucumber/two_scenarios_with_background_fail @@ -20,7 +20,7 @@ "name": "passing step", "line": 4, "match": { - "location": "formatters_print_test.go:63" + "location": "fmt_output_test.go:97" }, "result": { "status": "passed", @@ -32,7 +32,7 @@ "name": "failing step", "line": 5, "match": { - "location": "formatters_print_test.go:79" + "location": "fmt_output_test.go:113" }, "result": { "status": "failed", @@ -45,7 +45,7 @@ "name": "passing step", "line": 8, "match": { - "location": "formatters_print_test.go:63" + "location": "fmt_output_test.go:97" }, "result": { "status": "skipped" @@ -56,7 +56,7 @@ "name": "passing step", "line": 9, "match": { - "location": "formatters_print_test.go:63" + "location": "fmt_output_test.go:97" }, "result": { "status": "skipped" @@ -77,7 +77,7 @@ "name": "passing step", "line": 4, "match": { - "location": "formatters_print_test.go:63" + "location": "fmt_output_test.go:97" }, "result": { "status": "passed", @@ -89,7 +89,7 @@ "name": "failing step", "line": 5, "match": { - "location": "formatters_print_test.go:79" + "location": "fmt_output_test.go:113" }, "result": { "status": "failed", @@ -102,7 +102,7 @@ "name": "passing step", "line": 12, "match": { - "location": "formatters_print_test.go:63" + "location": "fmt_output_test.go:97" }, "result": { "status": "skipped" diff --git a/formatter-tests/events/scenario_outline b/formatter-tests/events/scenario_outline index adab074..f040ac3 100644 --- a/formatter-tests/events/scenario_outline +++ b/formatter-tests/events/scenario_outline @@ -1,57 +1,57 @@ {"event":"TestRunStarted","version":"0.1.0","timestamp":-6795364578871,"suite":"events"} {"event":"TestSource","location":"formatter-tests/features/scenario_outline.feature:2","source":"@outline @tag\nFeature: outline\n\n @scenario\n Scenario Outline: outline\n Given passing step\n When passing step\n Then odd \u003codd\u003e and even \u003ceven\u003e number\n\n @tagged\n Examples: tagged\n | odd | even |\n | 1 | 2 |\n | 2 | 0 |\n | 3 | 11 |\n\n @tag2\n Examples:\n | odd | even |\n | 1 | 14 |\n | 3 | 9 |\n"} {"event":"TestCaseStarted","location":"formatter-tests/features/scenario_outline.feature:13","timestamp":-6795364578871} -{"event":"StepDefinitionFound","location":"formatter-tests/features/scenario_outline.feature:6","definition_id":"formatters_print_test.go:63 -\u003e passingStepDef","arguments":[]} +{"event":"StepDefinitionFound","location":"formatter-tests/features/scenario_outline.feature:6","definition_id":"fmt_output_test.go:97 -\u003e github.com/cucumber/godog_test.passingStepDef","arguments":[]} {"event":"TestStepStarted","location":"formatter-tests/features/scenario_outline.feature:6","timestamp":-6795364578871} {"event":"TestStepFinished","location":"formatter-tests/features/scenario_outline.feature:6","timestamp":-6795364578871,"status":"passed"} -{"event":"StepDefinitionFound","location":"formatter-tests/features/scenario_outline.feature:7","definition_id":"formatters_print_test.go:63 -\u003e passingStepDef","arguments":[]} +{"event":"StepDefinitionFound","location":"formatter-tests/features/scenario_outline.feature:7","definition_id":"fmt_output_test.go:97 -\u003e github.com/cucumber/godog_test.passingStepDef","arguments":[]} {"event":"TestStepStarted","location":"formatter-tests/features/scenario_outline.feature:7","timestamp":-6795364578871} {"event":"TestStepFinished","location":"formatter-tests/features/scenario_outline.feature:7","timestamp":-6795364578871,"status":"passed"} -{"event":"StepDefinitionFound","location":"formatter-tests/features/scenario_outline.feature:8","definition_id":"formatters_print_test.go:65 -\u003e oddEvenStepDef","arguments":[[4,5],[5,15]]} +{"event":"StepDefinitionFound","location":"formatter-tests/features/scenario_outline.feature:8","definition_id":"fmt_output_test.go:99 -\u003e github.com/cucumber/godog_test.oddEvenStepDef","arguments":[[4,5],[5,15]]} {"event":"TestStepStarted","location":"formatter-tests/features/scenario_outline.feature:8","timestamp":-6795364578871} {"event":"TestStepFinished","location":"formatter-tests/features/scenario_outline.feature:8","timestamp":-6795364578871,"status":"passed"} {"event":"TestCaseFinished","location":"formatter-tests/features/scenario_outline.feature:13","timestamp":-6795364578871,"status":"passed"} {"event":"TestCaseStarted","location":"formatter-tests/features/scenario_outline.feature:14","timestamp":-6795364578871} -{"event":"StepDefinitionFound","location":"formatter-tests/features/scenario_outline.feature:6","definition_id":"formatters_print_test.go:63 -\u003e passingStepDef","arguments":[]} +{"event":"StepDefinitionFound","location":"formatter-tests/features/scenario_outline.feature:6","definition_id":"fmt_output_test.go:97 -\u003e github.com/cucumber/godog_test.passingStepDef","arguments":[]} {"event":"TestStepStarted","location":"formatter-tests/features/scenario_outline.feature:6","timestamp":-6795364578871} {"event":"TestStepFinished","location":"formatter-tests/features/scenario_outline.feature:6","timestamp":-6795364578871,"status":"passed"} -{"event":"StepDefinitionFound","location":"formatter-tests/features/scenario_outline.feature:7","definition_id":"formatters_print_test.go:63 -\u003e passingStepDef","arguments":[]} +{"event":"StepDefinitionFound","location":"formatter-tests/features/scenario_outline.feature:7","definition_id":"fmt_output_test.go:97 -\u003e github.com/cucumber/godog_test.passingStepDef","arguments":[]} {"event":"TestStepStarted","location":"formatter-tests/features/scenario_outline.feature:7","timestamp":-6795364578871} {"event":"TestStepFinished","location":"formatter-tests/features/scenario_outline.feature:7","timestamp":-6795364578871,"status":"passed"} -{"event":"StepDefinitionFound","location":"formatter-tests/features/scenario_outline.feature:8","definition_id":"formatters_print_test.go:65 -\u003e oddEvenStepDef","arguments":[[4,5],[5,15]]} +{"event":"StepDefinitionFound","location":"formatter-tests/features/scenario_outline.feature:8","definition_id":"fmt_output_test.go:99 -\u003e github.com/cucumber/godog_test.oddEvenStepDef","arguments":[[4,5],[5,15]]} {"event":"TestStepStarted","location":"formatter-tests/features/scenario_outline.feature:8","timestamp":-6795364578871} {"event":"TestStepFinished","location":"formatter-tests/features/scenario_outline.feature:8","timestamp":-6795364578871,"status":"failed","summary":"2 is not odd"} {"event":"TestCaseFinished","location":"formatter-tests/features/scenario_outline.feature:14","timestamp":-6795364578871,"status":"failed"} {"event":"TestCaseStarted","location":"formatter-tests/features/scenario_outline.feature:15","timestamp":-6795364578871} -{"event":"StepDefinitionFound","location":"formatter-tests/features/scenario_outline.feature:6","definition_id":"formatters_print_test.go:63 -\u003e passingStepDef","arguments":[]} +{"event":"StepDefinitionFound","location":"formatter-tests/features/scenario_outline.feature:6","definition_id":"fmt_output_test.go:97 -\u003e github.com/cucumber/godog_test.passingStepDef","arguments":[]} {"event":"TestStepStarted","location":"formatter-tests/features/scenario_outline.feature:6","timestamp":-6795364578871} {"event":"TestStepFinished","location":"formatter-tests/features/scenario_outline.feature:6","timestamp":-6795364578871,"status":"passed"} -{"event":"StepDefinitionFound","location":"formatter-tests/features/scenario_outline.feature:7","definition_id":"formatters_print_test.go:63 -\u003e passingStepDef","arguments":[]} +{"event":"StepDefinitionFound","location":"formatter-tests/features/scenario_outline.feature:7","definition_id":"fmt_output_test.go:97 -\u003e github.com/cucumber/godog_test.passingStepDef","arguments":[]} {"event":"TestStepStarted","location":"formatter-tests/features/scenario_outline.feature:7","timestamp":-6795364578871} {"event":"TestStepFinished","location":"formatter-tests/features/scenario_outline.feature:7","timestamp":-6795364578871,"status":"passed"} -{"event":"StepDefinitionFound","location":"formatter-tests/features/scenario_outline.feature:8","definition_id":"formatters_print_test.go:65 -\u003e oddEvenStepDef","arguments":[[4,5],[5,15]]} +{"event":"StepDefinitionFound","location":"formatter-tests/features/scenario_outline.feature:8","definition_id":"fmt_output_test.go:99 -\u003e github.com/cucumber/godog_test.oddEvenStepDef","arguments":[[4,5],[5,15]]} {"event":"TestStepStarted","location":"formatter-tests/features/scenario_outline.feature:8","timestamp":-6795364578871} {"event":"TestStepFinished","location":"formatter-tests/features/scenario_outline.feature:8","timestamp":-6795364578871,"status":"failed","summary":"11 is not even"} {"event":"TestCaseFinished","location":"formatter-tests/features/scenario_outline.feature:15","timestamp":-6795364578871,"status":"failed"} {"event":"TestCaseStarted","location":"formatter-tests/features/scenario_outline.feature:20","timestamp":-6795364578871} -{"event":"StepDefinitionFound","location":"formatter-tests/features/scenario_outline.feature:6","definition_id":"formatters_print_test.go:63 -\u003e passingStepDef","arguments":[]} +{"event":"StepDefinitionFound","location":"formatter-tests/features/scenario_outline.feature:6","definition_id":"fmt_output_test.go:97 -\u003e github.com/cucumber/godog_test.passingStepDef","arguments":[]} {"event":"TestStepStarted","location":"formatter-tests/features/scenario_outline.feature:6","timestamp":-6795364578871} {"event":"TestStepFinished","location":"formatter-tests/features/scenario_outline.feature:6","timestamp":-6795364578871,"status":"passed"} -{"event":"StepDefinitionFound","location":"formatter-tests/features/scenario_outline.feature:7","definition_id":"formatters_print_test.go:63 -\u003e passingStepDef","arguments":[]} +{"event":"StepDefinitionFound","location":"formatter-tests/features/scenario_outline.feature:7","definition_id":"fmt_output_test.go:97 -\u003e github.com/cucumber/godog_test.passingStepDef","arguments":[]} {"event":"TestStepStarted","location":"formatter-tests/features/scenario_outline.feature:7","timestamp":-6795364578871} {"event":"TestStepFinished","location":"formatter-tests/features/scenario_outline.feature:7","timestamp":-6795364578871,"status":"passed"} -{"event":"StepDefinitionFound","location":"formatter-tests/features/scenario_outline.feature:8","definition_id":"formatters_print_test.go:65 -\u003e oddEvenStepDef","arguments":[[4,5],[5,15]]} +{"event":"StepDefinitionFound","location":"formatter-tests/features/scenario_outline.feature:8","definition_id":"fmt_output_test.go:99 -\u003e github.com/cucumber/godog_test.oddEvenStepDef","arguments":[[4,5],[5,15]]} {"event":"TestStepStarted","location":"formatter-tests/features/scenario_outline.feature:8","timestamp":-6795364578871} {"event":"TestStepFinished","location":"formatter-tests/features/scenario_outline.feature:8","timestamp":-6795364578871,"status":"passed"} {"event":"TestCaseFinished","location":"formatter-tests/features/scenario_outline.feature:20","timestamp":-6795364578871,"status":"passed"} {"event":"TestCaseStarted","location":"formatter-tests/features/scenario_outline.feature:21","timestamp":-6795364578871} -{"event":"StepDefinitionFound","location":"formatter-tests/features/scenario_outline.feature:6","definition_id":"formatters_print_test.go:63 -\u003e passingStepDef","arguments":[]} +{"event":"StepDefinitionFound","location":"formatter-tests/features/scenario_outline.feature:6","definition_id":"fmt_output_test.go:97 -\u003e github.com/cucumber/godog_test.passingStepDef","arguments":[]} {"event":"TestStepStarted","location":"formatter-tests/features/scenario_outline.feature:6","timestamp":-6795364578871} {"event":"TestStepFinished","location":"formatter-tests/features/scenario_outline.feature:6","timestamp":-6795364578871,"status":"passed"} -{"event":"StepDefinitionFound","location":"formatter-tests/features/scenario_outline.feature:7","definition_id":"formatters_print_test.go:63 -\u003e passingStepDef","arguments":[]} +{"event":"StepDefinitionFound","location":"formatter-tests/features/scenario_outline.feature:7","definition_id":"fmt_output_test.go:97 -\u003e github.com/cucumber/godog_test.passingStepDef","arguments":[]} {"event":"TestStepStarted","location":"formatter-tests/features/scenario_outline.feature:7","timestamp":-6795364578871} {"event":"TestStepFinished","location":"formatter-tests/features/scenario_outline.feature:7","timestamp":-6795364578871,"status":"passed"} -{"event":"StepDefinitionFound","location":"formatter-tests/features/scenario_outline.feature:8","definition_id":"formatters_print_test.go:65 -\u003e oddEvenStepDef","arguments":[[4,5],[5,15]]} +{"event":"StepDefinitionFound","location":"formatter-tests/features/scenario_outline.feature:8","definition_id":"fmt_output_test.go:99 -\u003e github.com/cucumber/godog_test.oddEvenStepDef","arguments":[[4,5],[5,15]]} {"event":"TestStepStarted","location":"formatter-tests/features/scenario_outline.feature:8","timestamp":-6795364578871} {"event":"TestStepFinished","location":"formatter-tests/features/scenario_outline.feature:8","timestamp":-6795364578871,"status":"failed","summary":"9 is not even"} {"event":"TestCaseFinished","location":"formatter-tests/features/scenario_outline.feature:21","timestamp":-6795364578871,"status":"failed"} diff --git a/formatter-tests/events/scenario_with_background b/formatter-tests/events/scenario_with_background index 84d8dbe..a48ea68 100644 --- a/formatter-tests/events/scenario_with_background +++ b/formatter-tests/events/scenario_with_background @@ -1,16 +1,16 @@ {"event":"TestRunStarted","version":"0.1.0","timestamp":-6795364578871,"suite":"events"} {"event":"TestSource","location":"formatter-tests/features/scenario_with_background.feature:1","source":"Feature: single scenario with background\n\n Background: named\n Given passing step\n And passing step\n\n Scenario: scenario\n When passing step\n Then passing step\n"} {"event":"TestCaseStarted","location":"formatter-tests/features/scenario_with_background.feature:7","timestamp":-6795364578871} -{"event":"StepDefinitionFound","location":"formatter-tests/features/scenario_with_background.feature:4","definition_id":"formatters_print_test.go:63 -\u003e passingStepDef","arguments":[]} +{"event":"StepDefinitionFound","location":"formatter-tests/features/scenario_with_background.feature:4","definition_id":"fmt_output_test.go:97 -\u003e github.com/cucumber/godog_test.passingStepDef","arguments":[]} {"event":"TestStepStarted","location":"formatter-tests/features/scenario_with_background.feature:4","timestamp":-6795364578871} {"event":"TestStepFinished","location":"formatter-tests/features/scenario_with_background.feature:4","timestamp":-6795364578871,"status":"passed"} -{"event":"StepDefinitionFound","location":"formatter-tests/features/scenario_with_background.feature:5","definition_id":"formatters_print_test.go:63 -\u003e passingStepDef","arguments":[]} +{"event":"StepDefinitionFound","location":"formatter-tests/features/scenario_with_background.feature:5","definition_id":"fmt_output_test.go:97 -\u003e github.com/cucumber/godog_test.passingStepDef","arguments":[]} {"event":"TestStepStarted","location":"formatter-tests/features/scenario_with_background.feature:5","timestamp":-6795364578871} {"event":"TestStepFinished","location":"formatter-tests/features/scenario_with_background.feature:5","timestamp":-6795364578871,"status":"passed"} -{"event":"StepDefinitionFound","location":"formatter-tests/features/scenario_with_background.feature:8","definition_id":"formatters_print_test.go:63 -\u003e passingStepDef","arguments":[]} +{"event":"StepDefinitionFound","location":"formatter-tests/features/scenario_with_background.feature:8","definition_id":"fmt_output_test.go:97 -\u003e github.com/cucumber/godog_test.passingStepDef","arguments":[]} {"event":"TestStepStarted","location":"formatter-tests/features/scenario_with_background.feature:8","timestamp":-6795364578871} {"event":"TestStepFinished","location":"formatter-tests/features/scenario_with_background.feature:8","timestamp":-6795364578871,"status":"passed"} -{"event":"StepDefinitionFound","location":"formatter-tests/features/scenario_with_background.feature:9","definition_id":"formatters_print_test.go:63 -\u003e passingStepDef","arguments":[]} +{"event":"StepDefinitionFound","location":"formatter-tests/features/scenario_with_background.feature:9","definition_id":"fmt_output_test.go:97 -\u003e github.com/cucumber/godog_test.passingStepDef","arguments":[]} {"event":"TestStepStarted","location":"formatter-tests/features/scenario_with_background.feature:9","timestamp":-6795364578871} {"event":"TestStepFinished","location":"formatter-tests/features/scenario_with_background.feature:9","timestamp":-6795364578871,"status":"passed"} {"event":"TestCaseFinished","location":"formatter-tests/features/scenario_with_background.feature:7","timestamp":-6795364578871,"status":"passed"} diff --git a/formatter-tests/events/single_scenario_with_passing_step b/formatter-tests/events/single_scenario_with_passing_step index 210399c..b9afac6 100644 --- a/formatter-tests/events/single_scenario_with_passing_step +++ b/formatter-tests/events/single_scenario_with_passing_step @@ -1,7 +1,7 @@ {"event":"TestRunStarted","version":"0.1.0","timestamp":-6795364578871,"suite":"events"} {"event":"TestSource","location":"formatter-tests/features/single_scenario_with_passing_step.feature:1","source":"Feature: single passing scenario\n describes\n a single scenario\n feature\n\n Scenario: one step passing\n Given a passing step\n"} {"event":"TestCaseStarted","location":"formatter-tests/features/single_scenario_with_passing_step.feature:6","timestamp":-6795364578871} -{"event":"StepDefinitionFound","location":"formatter-tests/features/single_scenario_with_passing_step.feature:7","definition_id":"formatters_print_test.go:63 -\u003e passingStepDef","arguments":[]} +{"event":"StepDefinitionFound","location":"formatter-tests/features/single_scenario_with_passing_step.feature:7","definition_id":"fmt_output_test.go:97 -\u003e github.com/cucumber/godog_test.passingStepDef","arguments":[]} {"event":"TestStepStarted","location":"formatter-tests/features/single_scenario_with_passing_step.feature:7","timestamp":-6795364578871} {"event":"TestStepFinished","location":"formatter-tests/features/single_scenario_with_passing_step.feature:7","timestamp":-6795364578871,"status":"passed"} {"event":"TestCaseFinished","location":"formatter-tests/features/single_scenario_with_passing_step.feature:6","timestamp":-6795364578871,"status":"passed"} diff --git a/formatter-tests/events/some_scenarions_including_failing b/formatter-tests/events/some_scenarions_including_failing index 6fc70e1..2a37f6d 100644 --- a/formatter-tests/events/some_scenarions_including_failing +++ b/formatter-tests/events/some_scenarions_including_failing @@ -1,28 +1,28 @@ {"event":"TestRunStarted","version":"0.1.0","timestamp":-6795364578871,"suite":"events"} {"event":"TestSource","location":"formatter-tests/features/some_scenarions_including_failing.feature:1","source":"Feature: some scenarios\n\n Scenario: failing\n Given passing step\n When failing step\n Then passing step\n\n Scenario: pending\n When pending step\n Then passing step\n\n Scenario: undefined\n When undefined\n Then passing step\n"} {"event":"TestCaseStarted","location":"formatter-tests/features/some_scenarions_including_failing.feature:3","timestamp":-6795364578871} -{"event":"StepDefinitionFound","location":"formatter-tests/features/some_scenarions_including_failing.feature:4","definition_id":"formatters_print_test.go:63 -\u003e passingStepDef","arguments":[]} +{"event":"StepDefinitionFound","location":"formatter-tests/features/some_scenarions_including_failing.feature:4","definition_id":"fmt_output_test.go:97 -\u003e github.com/cucumber/godog_test.passingStepDef","arguments":[]} {"event":"TestStepStarted","location":"formatter-tests/features/some_scenarions_including_failing.feature:4","timestamp":-6795364578871} {"event":"TestStepFinished","location":"formatter-tests/features/some_scenarions_including_failing.feature:4","timestamp":-6795364578871,"status":"passed"} -{"event":"StepDefinitionFound","location":"formatter-tests/features/some_scenarions_including_failing.feature:5","definition_id":"formatters_print_test.go:79 -\u003e failingStepDef","arguments":[]} +{"event":"StepDefinitionFound","location":"formatter-tests/features/some_scenarions_including_failing.feature:5","definition_id":"fmt_output_test.go:113 -\u003e github.com/cucumber/godog_test.failingStepDef","arguments":[]} {"event":"TestStepStarted","location":"formatter-tests/features/some_scenarions_including_failing.feature:5","timestamp":-6795364578871} {"event":"TestStepFinished","location":"formatter-tests/features/some_scenarions_including_failing.feature:5","timestamp":-6795364578871,"status":"failed","summary":"step failed"} -{"event":"StepDefinitionFound","location":"formatter-tests/features/some_scenarions_including_failing.feature:6","definition_id":"formatters_print_test.go:63 -\u003e passingStepDef","arguments":[]} +{"event":"StepDefinitionFound","location":"formatter-tests/features/some_scenarions_including_failing.feature:6","definition_id":"fmt_output_test.go:97 -\u003e github.com/cucumber/godog_test.passingStepDef","arguments":[]} {"event":"TestStepStarted","location":"formatter-tests/features/some_scenarions_including_failing.feature:6","timestamp":-6795364578871} {"event":"TestStepFinished","location":"formatter-tests/features/some_scenarions_including_failing.feature:6","timestamp":-6795364578871,"status":"skipped"} {"event":"TestCaseFinished","location":"formatter-tests/features/some_scenarions_including_failing.feature:3","timestamp":-6795364578871,"status":"failed"} {"event":"TestCaseStarted","location":"formatter-tests/features/some_scenarions_including_failing.feature:8","timestamp":-6795364578871} -{"event":"StepDefinitionFound","location":"formatter-tests/features/some_scenarions_including_failing.feature:9","definition_id":"formatters_print_test.go:77 -\u003e pendingStepDef","arguments":[]} +{"event":"StepDefinitionFound","location":"formatter-tests/features/some_scenarions_including_failing.feature:9","definition_id":"fmt_output_test.go:111 -\u003e github.com/cucumber/godog_test.pendingStepDef","arguments":[]} {"event":"TestStepStarted","location":"formatter-tests/features/some_scenarions_including_failing.feature:9","timestamp":-6795364578871} {"event":"TestStepFinished","location":"formatter-tests/features/some_scenarions_including_failing.feature:9","timestamp":-6795364578871,"status":"pending"} -{"event":"StepDefinitionFound","location":"formatter-tests/features/some_scenarions_including_failing.feature:10","definition_id":"formatters_print_test.go:63 -\u003e passingStepDef","arguments":[]} +{"event":"StepDefinitionFound","location":"formatter-tests/features/some_scenarions_including_failing.feature:10","definition_id":"fmt_output_test.go:97 -\u003e github.com/cucumber/godog_test.passingStepDef","arguments":[]} {"event":"TestStepStarted","location":"formatter-tests/features/some_scenarions_including_failing.feature:10","timestamp":-6795364578871} {"event":"TestStepFinished","location":"formatter-tests/features/some_scenarions_including_failing.feature:10","timestamp":-6795364578871,"status":"skipped"} {"event":"TestCaseFinished","location":"formatter-tests/features/some_scenarions_including_failing.feature:8","timestamp":-6795364578871,"status":"pending"} {"event":"TestCaseStarted","location":"formatter-tests/features/some_scenarions_including_failing.feature:12","timestamp":-6795364578871} {"event":"TestStepStarted","location":"formatter-tests/features/some_scenarions_including_failing.feature:13","timestamp":-6795364578871} {"event":"TestStepFinished","location":"formatter-tests/features/some_scenarions_including_failing.feature:13","timestamp":-6795364578871,"status":"undefined"} -{"event":"StepDefinitionFound","location":"formatter-tests/features/some_scenarions_including_failing.feature:14","definition_id":"formatters_print_test.go:63 -\u003e passingStepDef","arguments":[]} +{"event":"StepDefinitionFound","location":"formatter-tests/features/some_scenarions_including_failing.feature:14","definition_id":"fmt_output_test.go:97 -\u003e github.com/cucumber/godog_test.passingStepDef","arguments":[]} {"event":"TestStepStarted","location":"formatter-tests/features/some_scenarions_including_failing.feature:14","timestamp":-6795364578871} {"event":"TestStepFinished","location":"formatter-tests/features/some_scenarions_including_failing.feature:14","timestamp":-6795364578871,"status":"skipped"} {"event":"TestCaseFinished","location":"formatter-tests/features/some_scenarions_including_failing.feature:12","timestamp":-6795364578871,"status":"undefined"} diff --git a/formatter-tests/events/two_scenarios_with_background_fail b/formatter-tests/events/two_scenarios_with_background_fail index e269ba8..2020e19 100644 --- a/formatter-tests/events/two_scenarios_with_background_fail +++ b/formatter-tests/events/two_scenarios_with_background_fail @@ -1,27 +1,27 @@ {"event":"TestRunStarted","version":"0.1.0","timestamp":-6795364578871,"suite":"events"} {"event":"TestSource","location":"formatter-tests/features/two_scenarios_with_background_fail.feature:1","source":"Feature: two scenarios with background fail\n\n Background:\n Given passing step\n And failing step\n\n Scenario: one\n When passing step\n Then passing step\n\n Scenario: two\n Then passing step\n"} {"event":"TestCaseStarted","location":"formatter-tests/features/two_scenarios_with_background_fail.feature:7","timestamp":-6795364578871} -{"event":"StepDefinitionFound","location":"formatter-tests/features/two_scenarios_with_background_fail.feature:4","definition_id":"formatters_print_test.go:63 -\u003e passingStepDef","arguments":[]} +{"event":"StepDefinitionFound","location":"formatter-tests/features/two_scenarios_with_background_fail.feature:4","definition_id":"fmt_output_test.go:97 -\u003e github.com/cucumber/godog_test.passingStepDef","arguments":[]} {"event":"TestStepStarted","location":"formatter-tests/features/two_scenarios_with_background_fail.feature:4","timestamp":-6795364578871} {"event":"TestStepFinished","location":"formatter-tests/features/two_scenarios_with_background_fail.feature:4","timestamp":-6795364578871,"status":"passed"} -{"event":"StepDefinitionFound","location":"formatter-tests/features/two_scenarios_with_background_fail.feature:5","definition_id":"formatters_print_test.go:79 -\u003e failingStepDef","arguments":[]} +{"event":"StepDefinitionFound","location":"formatter-tests/features/two_scenarios_with_background_fail.feature:5","definition_id":"fmt_output_test.go:113 -\u003e github.com/cucumber/godog_test.failingStepDef","arguments":[]} {"event":"TestStepStarted","location":"formatter-tests/features/two_scenarios_with_background_fail.feature:5","timestamp":-6795364578871} {"event":"TestStepFinished","location":"formatter-tests/features/two_scenarios_with_background_fail.feature:5","timestamp":-6795364578871,"status":"failed","summary":"step failed"} -{"event":"StepDefinitionFound","location":"formatter-tests/features/two_scenarios_with_background_fail.feature:8","definition_id":"formatters_print_test.go:63 -\u003e passingStepDef","arguments":[]} +{"event":"StepDefinitionFound","location":"formatter-tests/features/two_scenarios_with_background_fail.feature:8","definition_id":"fmt_output_test.go:97 -\u003e github.com/cucumber/godog_test.passingStepDef","arguments":[]} {"event":"TestStepStarted","location":"formatter-tests/features/two_scenarios_with_background_fail.feature:8","timestamp":-6795364578871} {"event":"TestStepFinished","location":"formatter-tests/features/two_scenarios_with_background_fail.feature:8","timestamp":-6795364578871,"status":"skipped"} -{"event":"StepDefinitionFound","location":"formatter-tests/features/two_scenarios_with_background_fail.feature:9","definition_id":"formatters_print_test.go:63 -\u003e passingStepDef","arguments":[]} +{"event":"StepDefinitionFound","location":"formatter-tests/features/two_scenarios_with_background_fail.feature:9","definition_id":"fmt_output_test.go:97 -\u003e github.com/cucumber/godog_test.passingStepDef","arguments":[]} {"event":"TestStepStarted","location":"formatter-tests/features/two_scenarios_with_background_fail.feature:9","timestamp":-6795364578871} {"event":"TestStepFinished","location":"formatter-tests/features/two_scenarios_with_background_fail.feature:9","timestamp":-6795364578871,"status":"skipped"} {"event":"TestCaseFinished","location":"formatter-tests/features/two_scenarios_with_background_fail.feature:7","timestamp":-6795364578871,"status":"failed"} {"event":"TestCaseStarted","location":"formatter-tests/features/two_scenarios_with_background_fail.feature:11","timestamp":-6795364578871} -{"event":"StepDefinitionFound","location":"formatter-tests/features/two_scenarios_with_background_fail.feature:4","definition_id":"formatters_print_test.go:63 -\u003e passingStepDef","arguments":[]} +{"event":"StepDefinitionFound","location":"formatter-tests/features/two_scenarios_with_background_fail.feature:4","definition_id":"fmt_output_test.go:97 -\u003e github.com/cucumber/godog_test.passingStepDef","arguments":[]} {"event":"TestStepStarted","location":"formatter-tests/features/two_scenarios_with_background_fail.feature:4","timestamp":-6795364578871} {"event":"TestStepFinished","location":"formatter-tests/features/two_scenarios_with_background_fail.feature:4","timestamp":-6795364578871,"status":"passed"} -{"event":"StepDefinitionFound","location":"formatter-tests/features/two_scenarios_with_background_fail.feature:5","definition_id":"formatters_print_test.go:79 -\u003e failingStepDef","arguments":[]} +{"event":"StepDefinitionFound","location":"formatter-tests/features/two_scenarios_with_background_fail.feature:5","definition_id":"fmt_output_test.go:113 -\u003e github.com/cucumber/godog_test.failingStepDef","arguments":[]} {"event":"TestStepStarted","location":"formatter-tests/features/two_scenarios_with_background_fail.feature:5","timestamp":-6795364578871} {"event":"TestStepFinished","location":"formatter-tests/features/two_scenarios_with_background_fail.feature:5","timestamp":-6795364578871,"status":"failed","summary":"step failed"} -{"event":"StepDefinitionFound","location":"formatter-tests/features/two_scenarios_with_background_fail.feature:12","definition_id":"formatters_print_test.go:63 -\u003e passingStepDef","arguments":[]} +{"event":"StepDefinitionFound","location":"formatter-tests/features/two_scenarios_with_background_fail.feature:12","definition_id":"fmt_output_test.go:97 -\u003e github.com/cucumber/godog_test.passingStepDef","arguments":[]} {"event":"TestStepStarted","location":"formatter-tests/features/two_scenarios_with_background_fail.feature:12","timestamp":-6795364578871} {"event":"TestStepFinished","location":"formatter-tests/features/two_scenarios_with_background_fail.feature:12","timestamp":-6795364578871,"status":"skipped"} {"event":"TestCaseFinished","location":"formatter-tests/features/two_scenarios_with_background_fail.feature:11","timestamp":-6795364578871,"status":"failed"} diff --git a/formatter-tests/pretty/scenario_outline b/formatter-tests/pretty/scenario_outline index 60d4e97..e2a0ee6 100644 --- a/formatter-tests/pretty/scenario_outline +++ b/formatter-tests/pretty/scenario_outline @@ -1,9 +1,9 @@ Feature: outline Scenario Outline: outline # formatter-tests/features/scenario_outline.feature:5 - Given passing step # formatters_print_test.go:63 -> passingStepDef - When passing step # formatters_print_test.go:63 -> passingStepDef - Then odd and even number # formatters_print_test.go:65 -> oddEvenStepDef + Given passing step # fmt_output_test.go:97 -> github.com/cucumber/godog_test.passingStepDef + When passing step # fmt_output_test.go:97 -> github.com/cucumber/godog_test.passingStepDef + Then odd and even number # fmt_output_test.go:99 -> github.com/cucumber/godog_test.oddEvenStepDef Examples: tagged | odd | even | diff --git a/formatter-tests/pretty/scenario_with_background b/formatter-tests/pretty/scenario_with_background index 21e098e..660d24b 100644 --- a/formatter-tests/pretty/scenario_with_background +++ b/formatter-tests/pretty/scenario_with_background @@ -1,12 +1,12 @@ Feature: single scenario with background Background: named - Given passing step # formatters_print_test.go:63 -> passingStepDef - And passing step # formatters_print_test.go:63 -> passingStepDef + Given passing step # fmt_output_test.go:97 -> github.com/cucumber/godog_test.passingStepDef + And passing step # fmt_output_test.go:97 -> github.com/cucumber/godog_test.passingStepDef Scenario: scenario # formatter-tests/features/scenario_with_background.feature:7 - When passing step # formatters_print_test.go:63 -> passingStepDef - Then passing step # formatters_print_test.go:63 -> passingStepDef + When passing step # fmt_output_test.go:97 -> github.com/cucumber/godog_test.passingStepDef + Then passing step # fmt_output_test.go:97 -> github.com/cucumber/godog_test.passingStepDef 1 scenarios (1 passed) 4 steps (4 passed) diff --git a/formatter-tests/pretty/single_scenario_with_passing_step b/formatter-tests/pretty/single_scenario_with_passing_step index bb94c08..33d3c0f 100644 --- a/formatter-tests/pretty/single_scenario_with_passing_step +++ b/formatter-tests/pretty/single_scenario_with_passing_step @@ -4,7 +4,7 @@ feature Scenario: one step passing # formatter-tests/features/single_scenario_with_passing_step.feature:6 - Given a passing step # formatters_print_test.go:63 -> passingStepDef + Given a passing step # fmt_output_test.go:97 -> github.com/cucumber/godog_test.passingStepDef 1 scenarios (1 passed) 1 steps (1 passed) diff --git a/formatter-tests/pretty/some_scenarions_including_failing b/formatter-tests/pretty/some_scenarions_including_failing index 4693204..4c0e88f 100644 --- a/formatter-tests/pretty/some_scenarions_including_failing +++ b/formatter-tests/pretty/some_scenarions_including_failing @@ -1,19 +1,19 @@ Feature: some scenarios Scenario: failing # formatter-tests/features/some_scenarions_including_failing.feature:3 - Given passing step # formatters_print_test.go:63 -> passingStepDef - When failing step # formatters_print_test.go:79 -> failingStepDef + Given passing step # fmt_output_test.go:97 -> github.com/cucumber/godog_test.passingStepDef + When failing step # fmt_output_test.go:113 -> github.com/cucumber/godog_test.failingStepDef step failed - Then passing step # formatters_print_test.go:63 -> passingStepDef + Then passing step # fmt_output_test.go:97 -> github.com/cucumber/godog_test.passingStepDef Scenario: pending # formatter-tests/features/some_scenarions_including_failing.feature:8 - When pending step # formatters_print_test.go:77 -> pendingStepDef + When pending step # fmt_output_test.go:111 -> github.com/cucumber/godog_test.pendingStepDef TODO: write pending definition - Then passing step # formatters_print_test.go:63 -> passingStepDef + Then passing step # fmt_output_test.go:97 -> github.com/cucumber/godog_test.passingStepDef Scenario: undefined # formatter-tests/features/some_scenarions_including_failing.feature:12 When undefined - Then passing step # formatters_print_test.go:63 -> passingStepDef + Then passing step # fmt_output_test.go:97 -> github.com/cucumber/godog_test.passingStepDef --- Failed steps: diff --git a/formatter-tests/pretty/two_scenarios_with_background_fail b/formatter-tests/pretty/two_scenarios_with_background_fail index c5b0969..be9f7c3 100644 --- a/formatter-tests/pretty/two_scenarios_with_background_fail +++ b/formatter-tests/pretty/two_scenarios_with_background_fail @@ -1,16 +1,16 @@ Feature: two scenarios with background fail Background: - Given passing step # formatters_print_test.go:63 -> passingStepDef - And failing step # formatters_print_test.go:79 -> failingStepDef + Given passing step # fmt_output_test.go:97 -> github.com/cucumber/godog_test.passingStepDef + And failing step # fmt_output_test.go:113 -> github.com/cucumber/godog_test.failingStepDef step failed Scenario: one # formatter-tests/features/two_scenarios_with_background_fail.feature:7 - When passing step # formatters_print_test.go:63 -> passingStepDef - Then passing step # formatters_print_test.go:63 -> passingStepDef + When passing step # fmt_output_test.go:97 -> github.com/cucumber/godog_test.passingStepDef + Then passing step # fmt_output_test.go:97 -> github.com/cucumber/godog_test.passingStepDef Scenario: two # formatter-tests/features/two_scenarios_with_background_fail.feature:11 - Then passing step # formatters_print_test.go:63 -> passingStepDef + Then passing step # fmt_output_test.go:97 -> github.com/cucumber/godog_test.passingStepDef --- Failed steps: diff --git a/formatters_print_test.go b/formatters_print_test.go deleted file mode 100644 index 890daa0..0000000 --- a/formatters_print_test.go +++ /dev/null @@ -1,79 +0,0 @@ -package godog - -import ( - "bytes" - "fmt" - "io/ioutil" - "os" - "path" - "strings" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -func TestPrintingFormatters(t *testing.T) { - features, err := parseFeatures("", []string{"formatter-tests"}) - require.NoError(t, err) - - var buf bytes.Buffer - out := &tagColorWriter{w: &buf} - - suite := &Suite{ - features: features, - } - - // inlining steps to have same source code line reference - suite.Step(`^(?:a )?failing step`, failingStepDef) - suite.Step(`^(?:a )?pending step$`, pendingStepDef) - suite.Step(`^(?:a )?passing step$`, passingStepDef) - suite.Step(`^odd (\d+) and even (\d+) number$`, oddEvenStepDef) - - pkg := os.Getenv("GODOG_TESTED_PACKAGE") - os.Setenv("GODOG_TESTED_PACKAGE", "github.com/cucumber/godog") - for _, feat := range features { - for name := range AvailableFormatters() { - expectOutputPath := strings.Replace(feat.Path, "features", name, 1) - expectOutputPath = strings.TrimSuffix(expectOutputPath, path.Ext(expectOutputPath)) - if _, err := os.Stat(expectOutputPath); err != nil { - continue - } - - buf.Reset() // flush the output - suite.fmt = FindFmt(name)(name, out) // prepare formatter - suite.features = []*feature{feat} // set the feature - - expectedOutput, err := ioutil.ReadFile(expectOutputPath) - require.NoError(t, err) - - suite.fmt.TestRunStarted() - suite.run() - suite.fmt.Summary() - - expected := string(expectedOutput) - actual := buf.String() - assert.Equalf(t, expected, actual, "path: %s", expectOutputPath) - } - } - - os.Setenv("GODOG_TESTED_PACKAGE", pkg) -} - -func passingStepDef() error { return nil } - -func oddEvenStepDef(odd, even int) error { return oddOrEven(odd, even) } - -func oddOrEven(odd, even int) error { - if odd%2 == 0 { - return fmt.Errorf("%d is not odd", odd) - } - if even%2 != 0 { - return fmt.Errorf("%d is not even", even) - } - return nil -} - -func pendingStepDef() error { return ErrPending } - -func failingStepDef() error { return fmt.Errorf("step failed") }