mirror of
https://github.com/jstemmer/go-junit-report.git
synced 2025-07-05 13:32:54 -05:00
junit: Remove benchmark specific code from package junit
The junit package shouldn't need to know anything about benchmarks and gtr.Benchmark will be removed in a future commit. Instead, it will be the responsibility of the gotest parser to represent benchmarks using gtr.Test.
This commit is contained in:
@ -160,10 +160,6 @@ func CreateFromReport(report gtr.Report, hostname string) Testsuites {
|
||||
suite.AddTestcase(createTestcaseForTest(pkg.Name, test))
|
||||
}
|
||||
|
||||
for _, bm := range pkg.Benchmarks {
|
||||
suite.AddTestcase(createTestcaseForBenchmark(pkg.Name, bm))
|
||||
}
|
||||
|
||||
// JUnit doesn't have a good way of dealing with build or runtime
|
||||
// errors that happen before a test has started, so we create a single
|
||||
// failing test that contains the build error details.
|
||||
@ -231,29 +227,6 @@ func createTestcaseForTest(pkgName string, test gtr.Test) Testcase {
|
||||
return tc
|
||||
}
|
||||
|
||||
func createTestcaseForBenchmark(pkgName string, bm gtr.Benchmark) Testcase {
|
||||
tc := Testcase{
|
||||
Classname: pkgName,
|
||||
Name: bm.Name,
|
||||
Time: formatDuration(bm.ApproximateDuration()),
|
||||
}
|
||||
|
||||
if bm.Result == gtr.Fail {
|
||||
tc.Failure = &Result{
|
||||
Message: "Failed",
|
||||
Data: formatOutput(bm.Output, 0),
|
||||
}
|
||||
} else if bm.Result == gtr.Skip {
|
||||
tc.Skipped = &Result{
|
||||
Message: "Skipped",
|
||||
Data: formatOutput(bm.Output, 0),
|
||||
}
|
||||
} else if len(bm.Output) > 0 {
|
||||
tc.SystemOut = &Output{Data: formatOutput(bm.Output, 0)}
|
||||
}
|
||||
return tc
|
||||
}
|
||||
|
||||
// formatDuration returns the JUnit string representation of the given
|
||||
// duration.
|
||||
func formatDuration(d time.Duration) string {
|
||||
|
Reference in New Issue
Block a user