From fe947a7587b4b8fcf6f35fb86c4a56f2eba05024 Mon Sep 17 00:00:00 2001 From: Viacheslav Poturaev Date: Thu, 31 Oct 2024 19:15:05 +0100 Subject: [PATCH] Use godog attachments (#12) --- formatter.go | 13 +++++++++++++ go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/formatter.go b/formatter.go index 0365b48..4e270a6 100644 --- a/formatter.go +++ b/formatter.go @@ -148,6 +148,8 @@ func (f *formatter) argumentAttachment(st *godog.Step) *report.Attachment { log.Fatal(err) } + att.Name = "argument value" + return att } else if st.Argument.DataTable != nil { var table [][]string @@ -166,6 +168,8 @@ func (f *formatter) argumentAttachment(st *godog.Step) *report.Attachment { log.Fatal(err) } + att.Name = "argument table" + return att } @@ -178,10 +182,19 @@ func (f *formatter) step(sc *godog.Scenario, st *godog.Step, status report.Statu c := f.scenarios[sc] c.finishedSteps++ + pickleStepResult := f.Storage.MustGetPickleStepResult(st.Id) + step := report.StepFinished(c.result, st.Text, status, statusDetails, func(s *report.Step) { if att := f.argumentAttachment(st); att != nil { s.Attachments = append(s.Attachments, *att) } + + for _, a := range pickleStepResult.Attachments { + if att, err := f.BytesAttachment(a.Data, a.MimeType); err == nil && att != nil { + att.Name = a.Name + s.Attachments = append(s.Attachments, *att) + } + } }, c.lastTime) f.LastTime = step.Stop diff --git a/go.mod b/go.mod index e14c0cb..5800a20 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( github.com/bool64/dev v0.2.35 - github.com/cucumber/godog v0.14.1 + github.com/cucumber/godog v0.15.0 github.com/google/uuid v1.6.0 github.com/stretchr/testify v1.8.2 ) diff --git a/go.sum b/go.sum index 337d227..7068a3a 100644 --- a/go.sum +++ b/go.sum @@ -3,8 +3,8 @@ github.com/bool64/dev v0.2.35/go.mod h1:iJbh1y/HkunEPhgebWRNcs8wfGq7sjvJ6W5iabL8 github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/cucumber/gherkin/go/v26 v26.2.0 h1:EgIjePLWiPeslwIWmNQ3XHcypPsWAHoMCz/YEBKP4GI= github.com/cucumber/gherkin/go/v26 v26.2.0/go.mod h1:t2GAPnB8maCT4lkHL99BDCVNzCh1d7dBhCLt150Nr/0= -github.com/cucumber/godog v0.14.1 h1:HGZhcOyyfaKclHjJ+r/q93iaTJZLKYW6Tv3HkmUE6+M= -github.com/cucumber/godog v0.14.1/go.mod h1:FX3rzIDybWABU4kuIXLZ/qtqEe1Ac5RdXmqvACJOces= +github.com/cucumber/godog v0.15.0 h1:51AL8lBXF3f0cyA5CV4TnJFCTHpgiy+1x1Hb3TtZUmo= +github.com/cucumber/godog v0.15.0/go.mod h1:FX3rzIDybWABU4kuIXLZ/qtqEe1Ac5RdXmqvACJOces= github.com/cucumber/messages/go/v21 v21.0.1 h1:wzA0LxwjlWQYZd32VTlAVDTkW6inOFmSM+RuOwHZiMI= github.com/cucumber/messages/go/v21 v21.0.1/go.mod h1:zheH/2HS9JLVFukdrsPWoPdmUtmYQAQPLk7w5vWsk5s= github.com/cucumber/messages/go/v22 v22.0.0/go.mod h1:aZipXTKc0JnjCsXrJnuZpWhtay93k7Rn3Dee7iyPJjs=