Skip to content
This repository has been archived by the owner on Feb 16, 2024. It is now read-only.

[Feature] - Aggregate and display failures at the bottom of output #30

Merged
merged 1 commit into from
Sep 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions pkg/test/harness.go
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,7 @@ func (h *Harness) Stop() {

h.kind = nil
}
h.DisplayFailedTest()
}

// wraps Test.Fatal in order to clean up harness
Expand Down Expand Up @@ -642,6 +643,30 @@ func (h *Harness) Report() {
}
}

func (h *Harness) DisplayFailedTest() {
h.logTotalFailures()
h.logEachTestSuiteFailures()
}

func (h *Harness) logTotalFailures() {
h.logger.Logf("Total test failures: %d", h.report.Failures)
}

func (h *Harness) logEachTestSuiteFailures() {
for _, suite := range h.report.Testsuite {
h.logger.Logf("Test suite %s: %d failures", suite.Name, suite.Failures)
h.logTestCaseFailures(suite)
}
}

func (h *Harness) logTestCaseFailures(suite *report.Testsuite) {
for _, testCase := range suite.Testcase {
if testCase.Failure != nil {
h.logger.Logf("test %s failed: %s", testCase.Name, testCase.Failure.Message)
}
}
}

// reportName returns the configured ReportName.
func (h *Harness) reportName() string {
if h.TestSuite.ReportName != "" {
Expand Down