Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix junit reporter for parallel testing #698

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions ginkgo_dsl.go
Expand Up @@ -191,13 +191,13 @@ type Benchmarker interface {
//
// ginkgo bootstrap
func RunSpecs(t GinkgoTestingT, description string) bool {
specReporters := []Reporter{buildDefaultReporter()}
var specReporters []Reporter

if config.DefaultReporterConfig.ReportFile != "" {
reportFile := config.DefaultReporterConfig.ReportFile
specReporters[0] = reporters.NewJUnitReporter(reportFile)
return RunSpecsWithDefaultAndCustomReporters(t, description, specReporters)
specReporters = append(specReporters, reporters.NewJUnitReporter(reportFile))
}
return RunSpecsWithCustomReporters(t, description, specReporters)
return RunSpecsWithDefaultAndCustomReporters(t, description, specReporters)
}

//To run your tests with Ginkgo's default reporter and your custom reporter(s), replace
Expand Down
7 changes: 7 additions & 0 deletions reporters/junit_reporter.go
Expand Up @@ -155,6 +155,13 @@ func (reporter *JUnitReporter) SpecSuiteDidEnd(summary *types.SuiteSummary) {
if err != nil {
fmt.Printf("\nFailed to create JUnit directory: %s\n\t%s", filePath, err.Error())
}

if config.GinkgoConfig.ParallelTotal > 1 {
ext := filepath.Ext(filePath)
filename := filePath[0:len(filePath)-len(ext)]
filePath = fmt.Sprintf("%s_%02d%s", filename, config.GinkgoConfig.ParallelNode, ext)
}

file, err := os.Create(filePath)
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to create JUnit report file: %s\n\t%s", filePath, err.Error())
Expand Down