Path: blob/main/vendor/github.com/sclevine/spec/report/terminal.go
2880 views
package report12import (3"fmt"4"io/ioutil"5"testing"67"github.com/sclevine/spec"8)910// Terminal reports specs via stdout.11type Terminal struct{}1213func (Terminal) Start(_ *testing.T, plan spec.Plan) {14fmt.Println("Suite:", plan.Text)15fmt.Printf("Total: %d | Focused: %d | Pending: %d\n", plan.Total, plan.Focused, plan.Pending)16if plan.HasRandom {17fmt.Println("Random seed:", plan.Seed)18}19if plan.HasFocus {20fmt.Println("Focus is active.")21}22}2324func (Terminal) Specs(_ *testing.T, specs <-chan spec.Spec) {25var passed, failed, skipped int26for s := range specs {27switch {28case s.Failed:29failed++30if !testing.Verbose() {31fmt.Print("x")32} else {33if out, err := ioutil.ReadAll(s.Out); err == nil {34fmt.Printf("%s\n", out)35}36}37case s.Skipped:38skipped++39if !testing.Verbose() {40fmt.Print("s")41}42default:43passed++44if !testing.Verbose() {45fmt.Print(".")46}47}48}49fmt.Printf("\nPassed: %d | Failed: %d | Skipped: %d\n\n", passed, failed, skipped)50}515253