diff --git a/reporters/junit_reporter.go b/reporters/junit_reporter.go index 65b8964e5..2c9f3c792 100644 --- a/reporters/junit_reporter.go +++ b/reporters/junit_reporter.go @@ -121,7 +121,7 @@ func (reporter *JUnitReporter) SpecDidComplete(specSummary *types.SpecSummary) { func (reporter *JUnitReporter) SpecSuiteDidEnd(summary *types.SuiteSummary) { reporter.suite.Tests = summary.NumberOfSpecsThatWillBeRun - reporter.suite.Time = math.Trunc(summary.RunTime.Seconds() * 1000 / 1000) + reporter.suite.Time = math.Trunc(summary.RunTime.Seconds()*1000) / 1000 reporter.suite.Failures = summary.NumberOfFailedSpecs reporter.suite.Errors = 0 file, err := os.Create(reporter.filename) diff --git a/reporters/junit_reporter_test.go b/reporters/junit_reporter_test.go index 605169cba..9b75dc006 100644 --- a/reporters/junit_reporter_test.go +++ b/reporters/junit_reporter_test.go @@ -19,7 +19,8 @@ var _ = Describe("JUnit Reporter", func() { outputFile string reporter Reporter ) - testSuiteTime := 12345 * time.Millisecond + testSuiteTime := 12456999 * time.Microsecond + reportedSuiteTime := 12.456 readOutputFile := func() reporters.JUnitTestSuite { bytes, err := ioutil.ReadFile(outputFile) @@ -80,7 +81,7 @@ var _ = Describe("JUnit Reporter", func() { Ω(output.Name).Should(Equal("My test suite")) Ω(output.Tests).Should(Equal(1)) Ω(output.Failures).Should(Equal(0)) - Ω(output.Time).Should(Equal(12.0)) + Ω(output.Time).Should(Equal(reportedSuiteTime)) Ω(output.Errors).Should(Equal(0)) Ω(output.TestCases).Should(HaveLen(1)) Ω(output.TestCases[0].Name).Should(Equal("A B C")) @@ -118,7 +119,7 @@ var _ = Describe("JUnit Reporter", func() { Ω(output.Name).Should(Equal("My test suite")) Ω(output.Tests).Should(Equal(1)) Ω(output.Failures).Should(Equal(1)) - Ω(output.Time).Should(Equal(12.0)) + Ω(output.Time).Should(Equal(reportedSuiteTime)) Ω(output.Errors).Should(Equal(0)) Ω(output.TestCases[0].Name).Should(Equal("BeforeSuite")) Ω(output.TestCases[0].Time).Should(Equal(3.0)) @@ -158,7 +159,7 @@ var _ = Describe("JUnit Reporter", func() { Ω(output.Name).Should(Equal("My test suite")) Ω(output.Tests).Should(Equal(1)) Ω(output.Failures).Should(Equal(1)) - Ω(output.Time).Should(Equal(12.0)) + Ω(output.Time).Should(Equal(reportedSuiteTime)) Ω(output.Errors).Should(Equal(0)) Ω(output.TestCases[0].Name).Should(Equal("AfterSuite")) Ω(output.TestCases[0].Time).Should(Equal(3.0)) @@ -210,7 +211,7 @@ var _ = Describe("JUnit Reporter", func() { Ω(output.Name).Should(Equal("My test suite")) Ω(output.Tests).Should(Equal(1)) Ω(output.Failures).Should(Equal(1)) - Ω(output.Time).Should(Equal(12.0)) + Ω(output.Time).Should(Equal(reportedSuiteTime)) Ω(output.Errors).Should(Equal(0)) Ω(output.TestCases[0].Name).Should(Equal("A B C")) Ω(output.TestCases[0].ClassName).Should(Equal("My test suite")) @@ -247,7 +248,7 @@ var _ = Describe("JUnit Reporter", func() { output := readOutputFile() Ω(output.Tests).Should(Equal(1)) Ω(output.Failures).Should(Equal(0)) - Ω(output.Time).Should(Equal(12.0)) + Ω(output.Time).Should(Equal(reportedSuiteTime)) Ω(output.Errors).Should(Equal(0)) Ω(output.TestCases[0].Name).Should(Equal("A B C")) Ω(output.TestCases[0].Skipped).ShouldNot(BeNil())