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