Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/skip it #82

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions goblin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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{}
Expand Down Expand Up @@ -267,6 +278,7 @@ type G struct {
shouldContinue chan bool
mutex sync.Mutex
timer *time.Timer
Skip Skip
}

func (g *G) SetReporter(r Reporter) {
Expand Down
36 changes: 36 additions & 0 deletions goblin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
})
})
})
}