From 10ac7158d186b6dd2bdd9fc5b558ec532af2e178 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20L=C3=B6nnblad?= Date: Mon, 20 Jan 2020 15:23:02 -0300 Subject: [PATCH] Fixed another time calc issue and added a Junit Concurrency run test --- fmt.go | 5 ++--- fmt_junit.go | 3 +++ run_test.go | 28 ++++++++++++++-------------- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/fmt.go b/fmt.go index 12167a8..3799309 100644 --- a/fmt.go +++ b/fmt.go @@ -242,8 +242,7 @@ func (f *basefmt) Node(n interface{}) { case *gherkin.Scenario: f.owner = t feature := f.features[len(f.features)-1] - feature.time = timeNowFunc() - feature.Scenarios = append(feature.Scenarios, &scenario{Name: t.Name, time: feature.time}) + feature.Scenarios = append(feature.Scenarios, &scenario{Name: t.Name, time: timeNowFunc()}) case *gherkin.ScenarioOutline: feature := f.features[len(f.features)-1] feature.Scenarios = append(feature.Scenarios, &scenario{OutlineName: t.Name}) @@ -270,7 +269,7 @@ func (f *basefmt) Defined(*gherkin.Step, *StepDef) { } func (f *basefmt) Feature(ft *gherkin.Feature, p string, c []byte) { - f.features = append(f.features, &feature{Path: p, Feature: ft}) + f.features = append(f.features, &feature{Path: p, Feature: ft, time: timeNowFunc()}) } func (f *basefmt) Passed(step *gherkin.Step, match *StepDef) { diff --git a/fmt_junit.go b/fmt_junit.go index 64374df..8f3dcfa 100644 --- a/fmt_junit.go +++ b/fmt_junit.go @@ -5,6 +5,7 @@ import ( "fmt" "io" "os" + "sort" "sync" "time" @@ -125,6 +126,8 @@ func buildJUNITPackageSuite(suiteName string, startedAt time.Time, features []*f Time: timeNowFunc().Sub(startedAt).String(), } + sort.Sort(sortByOrderGiven(features)) + for idx, feat := range features { ts := junitTestSuite{ Name: feat.Name, diff --git a/run_test.go b/run_test.go index ffbc241..64cbd59 100644 --- a/run_test.go +++ b/run_test.go @@ -342,14 +342,6 @@ func TestSucceedWithJunitAndConcurrencyOption(t *testing.T) { - - - - - - - - @@ -358,6 +350,14 @@ func TestSucceedWithJunitAndConcurrencyOption(t *testing.T) { + + + + + + + + @@ -394,12 +394,6 @@ func TestSucceedWithJunitAndConcurrencyOption(t *testing.T) { - - - - - - @@ -408,6 +402,12 @@ func TestSucceedWithJunitAndConcurrencyOption(t *testing.T) { + + + + + + ` status := RunWithOptions("succeed", func(s *Suite) { SuiteContext(s) }, opt)