Deprecated Time field, use a time.Duration instead.

The parser.Package.Time and parser.Test.Time fields are currently still
supported, but will be removed in the future.
This commit is contained in:
Joël Stemmer
2018-04-21 17:09:34 +01:00
parent c1eb342963
commit 1ce4b93a20
4 changed files with 441 additions and 305 deletions

View File

@ -7,6 +7,7 @@ import (
"io"
"runtime"
"strings"
"time"
"github.com/jstemmer/go-junit-report/parser"
)
@ -67,7 +68,7 @@ func JUnitReportXML(report *parser.Report, noXMLHeader bool, goVersion string, w
ts := JUnitTestSuite{
Tests: len(pkg.Tests),
Failures: 0,
Time: formatTime(pkg.Time),
Time: formatTime(pkg.Duration),
Name: pkg.Name,
Properties: []JUnitProperty{},
TestCases: []JUnitTestCase{},
@ -93,7 +94,7 @@ func JUnitReportXML(report *parser.Report, noXMLHeader bool, goVersion string, w
testCase := JUnitTestCase{
Classname: classname,
Name: test.Name,
Time: formatTime(test.Time),
Time: formatTime(test.Duration),
Failure: nil,
}
@ -135,6 +136,6 @@ func JUnitReportXML(report *parser.Report, noXMLHeader bool, goVersion string, w
return nil
}
func formatTime(time int) string {
return fmt.Sprintf("%.3f", float64(time)/1000.0)
func formatTime(d time.Duration) string {
return fmt.Sprintf("%.3f", d.Seconds())
}