This repository has been archived by the owner on Jan 26, 2022. It is now read-only.
/
default_reporter.go
73 lines (64 loc) · 2.98 KB
/
default_reporter.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
Ginkgo's Default Reporter
A number of command line flags are available to tweak Ginkgo's default output.
These are documented [here](http://onsi.github.io/ginkgo/#running_tests)
*/
package reporters
import (
"github.com/onsi/ginkgo/config"
"github.com/onsi/ginkgo/stenographer"
"github.com/onsi/ginkgo/types"
)
type DefaultReporter struct {
config config.DefaultReporterConfigType
stenographer stenographer.Stenographer
}
func NewDefaultReporter(config config.DefaultReporterConfigType, stenographer stenographer.Stenographer) *DefaultReporter {
return &DefaultReporter{
config: config,
stenographer: stenographer,
}
}
func (reporter *DefaultReporter) SpecSuiteWillBegin(config config.GinkgoConfigType, summary *types.SuiteSummary) {
reporter.stenographer.AnnounceSuite(summary.SuiteDescription, config.RandomSeed, config.RandomizeAllSpecs, reporter.config.Succinct)
if config.ParallelTotal > 1 {
reporter.stenographer.AnnounceParallelRun(config.ParallelNode, config.ParallelTotal, summary.NumberOfTotalExamples, summary.NumberOfExamplesBeforeParallelization, reporter.config.Succinct)
}
reporter.stenographer.AnnounceNumberOfSpecs(summary.NumberOfExamplesThatWillBeRun, summary.NumberOfTotalExamples, reporter.config.Succinct)
}
func (reporter *DefaultReporter) ExampleWillRun(exampleSummary *types.ExampleSummary) {
if reporter.config.Verbose && !reporter.config.Succinct && exampleSummary.State != types.ExampleStatePending && exampleSummary.State != types.ExampleStateSkipped {
reporter.stenographer.AnnounceExampleWillRun(exampleSummary)
}
}
func (reporter *DefaultReporter) ExampleDidComplete(exampleSummary *types.ExampleSummary) {
switch exampleSummary.State {
case types.ExampleStatePassed:
if !reporter.config.Succinct {
if exampleSummary.IsMeasurement {
reporter.stenographer.AnnounceSuccesfulMeasurement(exampleSummary, reporter.config.Succinct)
} else if exampleSummary.RunTime.Seconds() >= reporter.config.SlowSpecThreshold {
reporter.stenographer.AnnounceSuccesfulSlowExample(exampleSummary, reporter.config.Succinct)
} else {
reporter.stenographer.AnnounceSuccesfulExample(exampleSummary)
}
}
case types.ExampleStatePending:
if !reporter.config.Succinct {
reporter.stenographer.AnnouncePendingExample(exampleSummary, reporter.config.NoisyPendings, reporter.config.Succinct)
}
case types.ExampleStateSkipped:
if !reporter.config.Succinct {
reporter.stenographer.AnnounceSkippedExample(exampleSummary)
}
case types.ExampleStateTimedOut:
reporter.stenographer.AnnounceExampleTimedOut(exampleSummary, reporter.config.Succinct)
case types.ExampleStatePanicked:
reporter.stenographer.AnnounceExamplePanicked(exampleSummary, reporter.config.Succinct)
case types.ExampleStateFailed:
reporter.stenographer.AnnounceExampleFailed(exampleSummary, reporter.config.Succinct)
}
}
func (reporter *DefaultReporter) SpecSuiteDidEnd(summary *types.SuiteSummary) {
reporter.stenographer.AnnounceSpecRunCompletion(summary, reporter.config.Succinct)
}