diff --git a/internal/junitxml/report.go b/internal/junitxml/report.go index 1b50e816..d679a8cc 100644 --- a/internal/junitxml/report.go +++ b/internal/junitxml/report.go @@ -31,6 +31,7 @@ type JUnitTestSuite struct { Name string `xml:"name,attr"` Properties []JUnitProperty `xml:"properties>property,omitempty"` TestCases []JUnitTestCase + Timestamp string `xml:"timestamp,attr"` } // JUnitTestCase is a single test case with its result. @@ -92,6 +93,7 @@ func generate(exec *testjson.Execution, cfg Config) JUnitTestSuites { Properties: packageProperties(version), TestCases: packageTestCases(pkg, cfg.FormatTestCaseClassname), Failures: len(pkg.Failed), + Timestamp: exec.Started().Format(time.RFC3339), } suites.Suites = append(suites.Suites, junitpkg) } diff --git a/testjson/execution.go b/testjson/execution.go index 8be09395..a5c2f94c 100644 --- a/testjson/execution.go +++ b/testjson/execution.go @@ -564,6 +564,10 @@ func (e *Execution) end() []TestEvent { return result } +func (e *Execution) Started() time.Time { + return e.started +} + // newExecution returns a new Execution and records the current time as the // time the test execution started. func newExecution() *Execution {