diff --git a/formatters/fmt.go b/formatters/fmt.go index ea6f20ce..ca4d4b77 100644 --- a/formatters/fmt.go +++ b/formatters/fmt.go @@ -53,6 +53,14 @@ func AvailableFormatters() map[string]string { return fmts } +type MetaData struct{} + +type Source struct { + Data string + MediaType string + Uri string +} + // Formatter is an interface for feature runner // output summary presentation. // @@ -62,12 +70,21 @@ func AvailableFormatters() map[string]string { // godog.Format function call type Formatter interface { + // parsing phase messages + MetaData(*MetaData) + Source(*Source) + // Pickle() // TestRun() + // hooks - execution? - TestRunStarted() - Feature(*messages.GherkinDocument, string, []byte) - TestCaseStarted(*messages.Pickle) + // step matching phase messages Defined(*messages.Pickle, *messages.PickleStep, *StepDefinition) + + // execution phase messages + TestRunStarted() + Feature(*messages.GherkinDocument, string, []byte) // this one is not part of Messages, legacy + TestCase(*messages.Pickle) + TestCaseStarted(*messages.TestCaseStarted) Failed(*messages.Pickle, *messages.PickleStep, *StepDefinition, error) Passed(*messages.Pickle, *messages.PickleStep, *StepDefinition) Skipped(*messages.Pickle, *messages.PickleStep, *StepDefinition) diff --git a/internal/formatters/fmt_base.go b/internal/formatters/fmt_base.go index d84a4cf9..71cd5863 100644 --- a/internal/formatters/fmt_base.go +++ b/internal/formatters/fmt_base.go @@ -53,14 +53,23 @@ func (f *Base) SetStorage(st *storage.Storage) { f.Storage = st } +// Metadata is triggered prior to parsing +func (f *Base) MetaData(*formatters.MetaData) {} + +// Source is triggered prior to parsing +func (f *Base) Source(*formatters.Source) {} + // TestRunStarted is triggered on test start. func (f *Base) TestRunStarted() {} // Feature receives gherkin document. func (f *Base) Feature(*messages.GherkinDocument, string, []byte) {} -// TestCaseStarted receives scenario. -func (f *Base) TestCaseStarted(*messages.Pickle) {} +// TestCase receives scenario. +func (f *Base) TestCase(*messages.Pickle) {} + +// TestCaseStarted tracks attempt number and timestamp for a test case. +func (f *Base) TestCaseStarted(*messages.TestCaseStarted) {} // Defined receives step definition. func (f *Base) Defined(*messages.Pickle, *messages.PickleStep, *formatters.StepDefinition) { diff --git a/internal/formatters/fmt_events.go b/internal/formatters/fmt_events.go index 2a3c8a45..e52a2b8d 100644 --- a/internal/formatters/fmt_events.go +++ b/internal/formatters/fmt_events.go @@ -37,8 +37,8 @@ func (f *Events) event(ev interface{}) { } // Pickle receives scenario. -func (f *Events) TestCaseStarted(pickle *messages.Pickle) { - f.Base.TestCaseStarted(pickle) +func (f *Events) TestCase(pickle *messages.Pickle) { + f.Base.TestCase(pickle) f.Lock.Lock() defer f.Lock.Unlock() diff --git a/internal/formatters/fmt_multi.go b/internal/formatters/fmt_multi.go index 6f9b6ff4..fb6809cb 100644 --- a/internal/formatters/fmt_multi.go +++ b/internal/formatters/fmt_multi.go @@ -35,6 +35,12 @@ func (r repeater) SetStorage(s *storage.Storage) { } } +// Metadata is triggered prior to parsing +func (r repeater) MetaData(*formatters.MetaData) {} + +// Source is triggered prior to parsing +func (r repeater) Source(*formatters.Source) {} + // TestRunStarted triggers TestRunStarted for all added formatters. func (r repeater) TestRunStarted() { for _, f := range r { @@ -50,12 +56,16 @@ func (r repeater) Feature(document *messages.GherkinDocument, s string, bytes [] } // TestCaseStarted triggers TestCaseStarted for all added formatters. -func (r repeater) TestCaseStarted(pickle *messages.Pickle) { +func (r repeater) TestCase(pickle *messages.Pickle) { for _, f := range r { - f.TestCaseStarted(pickle) + f.TestCase(pickle) } } +func (r repeater) TestCaseStarted(*messages.TestCaseStarted) { + +} + // Defined triggers Defined for all added formatters. func (r repeater) Defined(pickle *messages.Pickle, step *messages.PickleStep, definition *formatters.StepDefinition) { for _, f := range r { diff --git a/internal/formatters/fmt_pretty.go b/internal/formatters/fmt_pretty.go index e99b49ed..ba2c7f5d 100644 --- a/internal/formatters/fmt_pretty.go +++ b/internal/formatters/fmt_pretty.go @@ -62,8 +62,8 @@ func (f *Pretty) Feature(gd *messages.GherkinDocument, p string, c []byte) { } // Pickle takes a gherkin node for formatting. -func (f *Pretty) TestCaseStarted(pickle *messages.Pickle) { - f.Base.TestCaseStarted(pickle) +func (f *Pretty) TestCase(pickle *messages.Pickle) { + f.Base.TestCase(pickle) f.Lock.Lock() defer f.Lock.Unlock() diff --git a/suite.go b/suite.go index 4b5ba2de..74cafec4 100644 --- a/suite.go +++ b/suite.go @@ -429,7 +429,7 @@ func (s *suite) runPickle(pickle *messages.Pickle) (err error) { pr := models.PickleResult{PickleID: pickle.Id, StartedAt: utils.TimeNowFunc()} s.storage.MustInsertPickleResult(pr) - s.fmt.TestCaseStarted(pickle) + s.fmt.TestCase(pickle) return ErrUndefined } @@ -439,7 +439,7 @@ func (s *suite) runPickle(pickle *messages.Pickle) (err error) { pr := models.PickleResult{PickleID: pickle.Id, StartedAt: utils.TimeNowFunc()} s.storage.MustInsertPickleResult(pr) - s.fmt.TestCaseStarted(pickle) + s.fmt.TestCase(pickle) // scenario if s.testingT != nil {