From 46ec5fdb90014cf491a6b2cc20b292c026ae283c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20L=C3=B6nnblad?= Date: Mon, 20 Jan 2020 15:51:32 -0300 Subject: [PATCH] a try to make the Junit test to pass on older go versions --- fmt_junit.go | 2 +- run_test.go | 147 ++++++++++++++++++++++++++------------------------- suite.go | 6 +++ 3 files changed, 82 insertions(+), 73 deletions(-) diff --git a/fmt_junit.go b/fmt_junit.go index 8f3dcfa..091c440 100644 --- a/fmt_junit.go +++ b/fmt_junit.go @@ -126,7 +126,7 @@ func buildJUNITPackageSuite(suiteName string, startedAt time.Time, features []*f Time: timeNowFunc().Sub(startedAt).String(), } - sort.Sort(sortByOrderGiven(features)) + sort.Sort(sortByName(features)) for idx, feat := range features { ts := junitTestSuite{ diff --git a/run_test.go b/run_test.go index 64cbd59..62ad6e7 100644 --- a/run_test.go +++ b/run_test.go @@ -8,6 +8,7 @@ import ( "os" "strings" "testing" + "time" "github.com/DATA-DOG/godog/colors" "github.com/DATA-DOG/godog/gherkin" @@ -324,89 +325,91 @@ func TestSucceedWithJunitAndConcurrencyOption(t *testing.T) { Output: output, } + zeroSecondsString := (0 * time.Second).String() + expectedOutput := ` - - - - - + + + + + + + + + + + - - - - - - - - - - + + + + - - - - - - - + + + + + + + - - - - + + + + - - + + + + + + + + + + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - - - - - - - - - + + + + + + + - - - - - - + + + + + - - - - - - - + + + + + + - - - - - + + ` diff --git a/suite.go b/suite.go index a5c7983..1950b7d 100644 --- a/suite.go +++ b/suite.go @@ -49,6 +49,12 @@ func (f feature) appendStepResult(s *stepResult) { scenario.Steps = append(scenario.Steps, s) } +type sortByName []*feature + +func (s sortByName) Len() int { return len(s) } +func (s sortByName) Less(i, j int) bool { return s[i].Name < s[j].Name } +func (s sortByName) Swap(i, j int) { s[i], s[j] = s[j], s[i] } + type scenario struct { Name string OutlineName string