Skip to content

Commit

Permalink
#341 continue refactor of formatter event names
Browse files Browse the repository at this point in the history
  • Loading branch information
dumpsterfireproject committed Jul 4, 2022
1 parent ce7586e commit 2eee46d
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 10 deletions.
3 changes: 2 additions & 1 deletion _examples/custom-formatter/emoji.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"math"

"github.com/cucumber/godog"
"github.com/cucumber/messages-go/v16"
)

const (
Expand Down Expand Up @@ -37,7 +38,7 @@ type emojiFmt struct {
out io.Writer
}

func (f *emojiFmt) TestRunStarted() {}
func (f *emojiFmt) TestRunStarted(t *messages.TestRunStarted) {}

func (f *emojiFmt) Passed(scenario *godog.Scenario, step *godog.Step, match *godog.StepDefinition) {
f.ProgressFmt.Base.Passed(scenario, step, match)
Expand Down
2 changes: 1 addition & 1 deletion formatters/fmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ type Formatter interface {
Defined(*messages.Pickle, *messages.PickleStep, *StepDefinition)

// execution phase messages
TestRunStarted()
TestRunStarted(*messages.TestRunStarted)
Feature(*messages.GherkinDocument, string, []byte) // this one is not part of Messages, legacy
TestCase(*messages.Pickle)
TestCaseStarted(*messages.TestCaseStarted)
Expand Down
2 changes: 1 addition & 1 deletion internal/formatters/fmt_base.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (f *Base) MetaData(*formatters.MetaData) {}
func (f *Base) Source(*formatters.Source) {}

// TestRunStarted is triggered on test start.
func (f *Base) TestRunStarted() {}
func (f *Base) TestRunStarted(*messages.TestRunStarted) {}

// Feature receives gherkin document.
func (f *Base) Feature(*messages.GherkinDocument, string, []byte) {}
Expand Down
4 changes: 2 additions & 2 deletions internal/formatters/fmt_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ func (f *Events) TestCase(pickle *messages.Pickle) {
}

// TestRunStarted is triggered on test start.
func (f *Events) TestRunStarted() {
f.Base.TestRunStarted()
func (f *Events) TestRunStarted(t *messages.TestRunStarted) {
f.Base.TestRunStarted(t)

f.Lock.Lock()
defer f.Lock.Unlock()
Expand Down
4 changes: 2 additions & 2 deletions internal/formatters/fmt_multi.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ func (r repeater) MetaData(*formatters.MetaData) {}
func (r repeater) Source(*formatters.Source) {}

// TestRunStarted triggers TestRunStarted for all added formatters.
func (r repeater) TestRunStarted() {
func (r repeater) TestRunStarted(t *messages.TestRunStarted) {
for _, f := range r {
f.TestRunStarted()
f.TestRunStarted(t)
}
}

Expand Down
4 changes: 2 additions & 2 deletions internal/formatters/fmt_pretty.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ type Pretty struct {
}

// TestRunStarted is triggered on test start.
func (f *Pretty) TestRunStarted() {
f.Base.TestRunStarted()
func (f *Pretty) TestRunStarted(t *messages.TestRunStarted) {
f.Base.TestRunStarted(t)

f.Lock.Lock()
defer f.Lock.Unlock()
Expand Down
3 changes: 2 additions & 1 deletion suite_context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,8 @@ func (tc *godogFeaturesScenario) iRunFeatureSuiteWithTagsAndFormatter(filter str

testRunStarted := models.TestRunStarted{StartedAt: utils.TimeNowFunc()}
tc.testedSuite.storage.MustInsertTestRunStarted(testRunStarted)
tc.testedSuite.fmt.TestRunStarted()
t := messages.GoTimeToTimestamp(testRunStarted.StartedAt)
tc.testedSuite.fmt.TestRunStarted(&messages.TestRunStarted{Timestamp: &t})

for _, f := range tc.testSuiteContext.beforeSuiteHandlers {
f()
Expand Down

0 comments on commit 2eee46d

Please sign in to comment.