Skip to content

Commit

Permalink
Always emit spec summary
Browse files Browse the repository at this point in the history
in V2 the spec summary behavior was changed such that the summary was only shown if there was more than one failure.  This breaks scrapers that rely on more consistent console output to analyze the test results.

With this commit, Ginkgo will always emit the summary.

Fixed #973
  • Loading branch information
onsi committed Aug 25, 2022
1 parent 3cd8b93 commit 5cf23e2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
8 changes: 6 additions & 2 deletions reporters/default_reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,13 @@ func (r *DefaultReporter) DidRun(report types.SpecReport) {

func (r *DefaultReporter) SuiteDidEnd(report types.Report) {
failures := report.SpecReports.WithState(types.SpecStateFailureStates)
if len(failures) > 1 {
if len(failures) > 0 {
r.emitBlock("\n\n")
r.emitBlock(r.f("{{red}}{{bold}}Summarizing %d Failures:{{/}}", len(failures)))
if len(failures) > 1 {
r.emitBlock(r.f("{{red}}{{bold}}Summarizing %d Failures:{{/}}", len(failures)))
} else {
r.emitBlock(r.f("{{red}}{{bold}}Summarizing 1 Failure:{{/}}"))
}
for _, specReport := range failures {
highlightColor, heading := "{{red}}", "[FAIL]"
switch specReport.State {
Expand Down
5 changes: 5 additions & 0 deletions reporters/default_reporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1135,6 +1135,11 @@ var _ = Describe("DefaultReporter", func() {
},
},
"",
"",
"{{red}}{{bold}}Summarizing 1 Failure:{{/}}",
" {{red}}[FAIL]{{/}} {{/}}Describe A {{gray}}{{red}}{{bold}}Context B [JustBeforeEach]{{/}} {{/}}The Test{{/}}",
" {{gray}}cl4.go:144{{/}}",
"",
"{{red}}{{bold}}Ran 6 of 11 Specs in 60.000 seconds{{/}}",
"{{red}}{{bold}}FAIL!{{/}} -- {{green}}{{bold}}5 Passed{{/}} | {{red}}{{bold}}1 Failed{{/}} | {{light-yellow}}{{bold}}2 Flaked{{/}} | {{yellow}}{{bold}}2 Pending{{/}} | {{cyan}}{{bold}}3 Skipped{{/}}",
"",
Expand Down

0 comments on commit 5cf23e2

Please sign in to comment.