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

Commit

Permalink
Merge pull request #30 from shubham-cmyk/display
Browse files Browse the repository at this point in the history
[Feature] - Aggregate and display failures at the bottom of output
  • Loading branch information
eddycharly authored Sep 11, 2023
2 parents 1e404d2 + 1285a70 commit 3561869
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions pkg/test/harness.go
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,7 @@ func (h *Harness) Stop() {

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

// wraps Test.Fatal in order to clean up harness
Expand Down Expand Up @@ -659,6 +660,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

0 comments on commit 3561869

Please sign in to comment.