Path: blob/main/vendor/github.com/sclevine/spec/report/log.go
2880 views
package report12import (3"io/ioutil"4"testing"56"github.com/sclevine/spec"7)89// Log reports specs via the testing log methods and only affects verbose runs.10type Log struct{}1112func (Log) Start(t *testing.T, plan spec.Plan) {13t.Helper()14t.Log("Suite:", plan.Text)15t.Logf("Total: %d | Focused: %d | Pending: %d", plan.Total, plan.Focused, plan.Pending)16if plan.HasRandom {17t.Log("Random seed:", plan.Seed)18}19if plan.HasFocus {20t.Log("Focus is active.")21}22}2324func (Log) Specs(t *testing.T, specs <-chan spec.Spec) {25t.Helper()26var passed, failed, skipped int27for s := range specs {28switch {29case s.Failed:30failed++31if testing.Verbose() {32if out, err := ioutil.ReadAll(s.Out); err == nil {33t.Logf("%s", out)34}35}36case s.Skipped:37skipped++38default:39passed++40}41}42t.Logf("Passed: %d | Failed: %d | Skipped: %d", passed, failed, skipped)43}444546