diff --git a/Spec.go b/Spec.go index 2df0ba4..ceeaa09 100644 --- a/Spec.go +++ b/Spec.go @@ -506,6 +506,7 @@ func (spec *Spec) runTB(tb testing.TB, blk func(*T)) { spec.doc.results = append(spec.doc.results, doc.TestingCase{ ContextPath: contextPath, TestFailed: tb.Failed(), + TestSkipped: tb.Skipped(), }) }() diff --git a/internal/doc/doc.go b/internal/doc/doc.go index 2b87f56..767106d 100644 --- a/internal/doc/doc.go +++ b/internal/doc/doc.go @@ -18,6 +18,8 @@ type TestingCase struct { ContextPath []string // TestFailed tells if the test failed TestFailed bool + // TestSkipped tells if the given test was skipped + TestSkipped bool } type DocumentFormat struct{} @@ -37,8 +39,9 @@ func (gen DocumentFormat) MakeDocument(ctx context.Context, tcs []TestingCase) ( type colourCode string const ( - red colourCode = "91m" - green colourCode = "92m" + red colourCode = "91m" + green colourCode = "92m" + yellow colourCode = "93m" ) func colourise(code colourCode, text string) string { @@ -97,6 +100,10 @@ func (gen DocumentFormat) generateDocumentString(n *node, indent string) string line = key colour = green ) + if child.TestingCase.TestSkipped { + line += " [SKIP]" + colour = yellow + } if child.TestingCase.TestFailed { line += " [FAIL]" colour = red diff --git a/internal/doc/doc_test.go b/internal/doc/doc_test.go index 85828e7..d6bd740 100644 --- a/internal/doc/doc_test.go +++ b/internal/doc/doc_test.go @@ -130,6 +130,31 @@ func TestTestDocumentGenerator(t *testing.T) { a.Case(func(t assert.It) { assert.Contain(t, d, exp2) }) }) }) + + t.Run("skipped tests are greyed out", func(t *testing.T) { + testcase.SetEnv(t, "TERM", "xterm-256color") + internal.StubVerbose(t, func() bool { + return true + }) + + docw := doc.DocumentFormat{} + + d, err := docw.MakeDocument(context.Background(), []doc.TestingCase{ + { + ContextPath: []string{ + "TestTestDocumentGenerator", + "smoke", + "testA", + }, + TestFailed: false, + TestSkipped: true, + }, + }) + assert.NoError(t, err) + + exp := "TestTestDocumentGenerator\n smoke\n \x1b[93mtestA [SKIP]\x1b[0m\n" + assert.Contain(t, d, exp) + }) } func Test_spike(t *testing.T) { @@ -155,6 +180,15 @@ func Test_spike(t *testing.T) { }, TestFailed: true, }, + { + ContextPath: []string{ + "subject", + "when", + "and", + "then C", + }, + TestSkipped: true, + }, }) assert.NoError(t, err)