From 72790bb33b31f27703e44e845d6cfc908918b7aa Mon Sep 17 00:00:00 2001 From: Simon Baeumer Date: Tue, 5 Jan 2021 17:00:00 +0100 Subject: [PATCH] add output --- pkg/app/test_command.go | 4 ++-- pkg/output/tap.go | 5 ++--- pkg/runtime/runtime.go | 8 ++++++++ 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/pkg/app/test_command.go b/pkg/app/test_command.go index 42797abb..15cbdfbd 100644 --- a/pkg/app/test_command.go +++ b/pkg/app/test_command.go @@ -33,7 +33,8 @@ func TestCommand(testPath string, ctx TestCommandContext) error { log.SetOutput(os.Stdout) } - out, err := output.NewOutput(ctx.Format, !ctx.NoColor) + var err error + out, err = output.NewOutput(ctx.Format, !ctx.NoColor) if err != nil { return err } @@ -66,7 +67,6 @@ func TestCommand(testPath string, ctx TestCommandContext) error { return fmt.Errorf(err.Error()) } - out.PrintSummary(result) if result.Failed != 0 && !ctx.Verbose { return fmt.Errorf("Test suite failed, use --verbose for more detailed output") diff --git a/pkg/output/tap.go b/pkg/output/tap.go index 929e2d4b..7f22be54 100644 --- a/pkg/output/tap.go +++ b/pkg/output/tap.go @@ -23,7 +23,7 @@ func NewTAPOutputWriter() Output { } func (w TAPOutputWriter) GetEventHandler() *runtime.EventHandler { - return nil + return runtime.NewEmptyEventHandler() } func (w TAPOutputWriter) PrintSummary(result runtime.Result) { @@ -37,8 +37,7 @@ func (w TAPOutputWriter) PrintSummary(result runtime.Result) { counter++ if r.FailedProperty != "" { w.fprintf("%d ok - %s", counter+1, r.TestCase.Title) - } - if r.FailedProperty != "" { + } else { w.fprintf("%d not ok - %s", counter+1, r.TestCase.Title) } } diff --git a/pkg/runtime/runtime.go b/pkg/runtime/runtime.go index 67613c6b..0601a76e 100644 --- a/pkg/runtime/runtime.go +++ b/pkg/runtime/runtime.go @@ -166,3 +166,11 @@ func (r *Runtime) Start(tests []TestCase) Result { return result } + +// NewEmptyEventHandler returns an event handler with empty implementations +func NewEmptyEventHandler() *EventHandler { + return &EventHandler{ + TestFinished: func(result TestResult) {}, + TestSkipped: func(result TestResult) {}, + } +}