Skip to content

Commit 658228e

Browse files
committed
Base functioninality done, need to switch to templare and add Summary
1 parent 9eebe69 commit 658228e

2 files changed

Lines changed: 19 additions & 6 deletions

File tree

pkg/output/cli.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ type TestResult struct {
4444
FailedProperty string
4545
Diff string
4646
Error error
47+
Skip bool
4748
}
4849

4950
// GetEventHandler create a new runtime.EventHandler
@@ -53,6 +54,12 @@ func (w *OutputWriter) GetEventHandler() *runtime.EventHandler {
5354
tr := convertTestResult(testResult)
5455
w.printResult(tr)
5556
}
57+
58+
handler.TestSkipped = func(testResult runtime.TestResult) {
59+
tr := convertTestResult(testResult)
60+
w.printSkipped(tr)
61+
}
62+
5663
return &handler
5764
}
5865

@@ -74,7 +81,7 @@ func (w *OutputWriter) PrintSummary(result runtime.Result) bool {
7481
return result.Failed == 0
7582
}
7683

77-
// PrintResult prints the simple output form of a TestReault
84+
// printResult prints the simple output form of a TestReault
7885
func (w *OutputWriter) printResult(r TestResult) {
7986
if !r.Success {
8087
w.fprintf(w.au.Red(w.template.testResult(r)))
@@ -83,6 +90,10 @@ func (w *OutputWriter) printResult(r TestResult) {
8390
w.fprintf(w.template.testResult(r))
8491
}
8592

93+
func (w *OutputWriter) printSkipped(r TestResult) {
94+
w.fprintf(fmt.Sprintf("- [skipped] %s: was skipped", r.Title))
95+
}
96+
8697
func (w *OutputWriter) printFailures(results []runtime.TestResult) {
8798
w.fprintf("")
8899
w.fprintf(w.au.Bold("Results"))
@@ -119,6 +130,7 @@ func convertTestResult(tr runtime.TestResult) TestResult {
119130
FailedProperty: tr.FailedProperty,
120131
Diff: tr.ValidationResult.Diff,
121132
Error: tr.TestCase.Result.Error,
133+
Skip: tr.Skipped,
122134
}
123135

124136
return testResult

pkg/runtime/runtime.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ type Runtime struct {
4242
// EventHandler is a configurable event system that handles events such as test completion
4343
type EventHandler struct {
4444
TestFinished func(TestResult)
45+
TestSkipped func(TestResult)
4546
}
4647

4748
// TestCase represents a test case which will be executed by the runtime
@@ -133,14 +134,14 @@ func (r *Runtime) Start(tests []TestCase) Result {
133134
testCh := r.Runner.Execute(tests)
134135
start := time.Now()
135136
for tr := range testCh {
136-
r.EventHandler.TestFinished(tr)
137-
138137
if tr.Skipped {
139-
result.Skipped++
140-
// Do not count as failed
141-
tr.ValidationResult.Success = true
138+
r.EventHandler.TestSkipped(tr)
139+
result.TestResults = append(result.TestResults, tr)
140+
continue
142141
}
143142

143+
r.EventHandler.TestFinished(tr)
144+
144145
if !tr.ValidationResult.Success {
145146
result.Failed++
146147
}

0 commit comments

Comments
 (0)