diff --git a/goblin.go b/goblin.go index 8585153..57acd49 100644 --- a/goblin.go +++ b/goblin.go @@ -166,6 +166,14 @@ func (it *It) failed(msg string, stack []string) { it.failure = &Failure{Stack: stack, Message: msg, TestName: it.parent.name + " " + it.name} } +type Skip struct { + g *G +} + +func (s *Skip) It(name string, h ...interface{}) { + s.g.Xit(name, h) +} + type Xit struct { h interface{} name string @@ -206,6 +214,9 @@ func Goblin(t *testing.T, arguments ...string) *G { parseFlags() } g := &G{t: t, timeout: *timeout} + g.Skip = Skip{ + g: g, + } var fancy TextFancier if *isTty { fancy = &TerminalFancier{} @@ -267,6 +278,7 @@ type G struct { shouldContinue chan bool mutex sync.Mutex timer *time.Timer + Skip Skip } func (g *G) SetReporter(r Reporter) { diff --git a/goblin_test.go b/goblin_test.go index 18669f1..d637959 100644 --- a/goblin_test.go +++ b/goblin_test.go @@ -433,3 +433,39 @@ func TestItTimeout(t *testing.T) { t.Fatal("Failed") } } + +func TestSkipIt(t *testing.T) { + g := Goblin(t) + + g.Describe("Describe with it, xit, skip.it", func() { + + g.It("This will run", func() { + g.Assert(2).Equal(2) + }) + + g.Xit("This will not run", func() { + g.Fail("Fail") + }) + + g.Skip.It("This will also not run", func() { + g.Fail("Fail") + }) + + g.Skip.It("Should be skipped and not fail", func(done Done) { + go func() { + g.Fail("Fail") + done() + }() + }) + }) + + g.Describe("Describe level 1", func() { + + g.Describe("Describe level 2", func() { + + g.Skip.It("This will also not run", func() { + g.Fail("Fail") + }) + }) + }) +}