Goblin is inspired by Mocha, and Mocha has a set of functions that allows you to skip tests.
Goblin supports skipping with Xit().
Xit("skip this", func(){})
Mocha allows you to invoke tests with a skip() function:
it.skip("skip this", function(){})
Since Go does not allow us to have a struct and a function with the same name we cannot have
g.It()// It is a function attached to the G struct
g.It.Skip() // It is a nested struct in G
Alternatively, and as a way to set up skipping It tests in a future PR, we can follow this pattern:
// skip this It test
g.Skip.It("skip this", func(){})
// skip all tests in this block
g.Skip.Describe("skip these", func(){
g.It("skip this", func(){})
})
Changes made
Add the ability to skip all tests within a describe block if it was added using g.Skip.Describe().
The before and after hooks on a skipped test in this Skip.Describe block behave the same way as g.Xit() tests - they do not run. Each Describe and It block within a Skip.Describe() will be logged in yellow.
Add a test for g.Skip.Describe()
Alternatives considered:
Tried adding a new struct Xdescribe which holds Describe.
The issue I ran into when trying to implement this is that each It and Describe block currently has a .parent field which references a *Describe block.
That would require a big refactor to convert every Describe and Xdescribe block to implement the same interface so that the .parent in every It and Describe will refer to this interface like Runnable().
I am not completely clear if this will work, but looking for feedback if you guys think this is the preferred solution @marcosnils @xetorthio
Motivations
Goblin is inspired by Mocha, and Mocha has a set of functions that allows you to skip tests. Goblin supports skipping with Xit().
Mocha allows you to invoke tests with a skip() function:
Since Go does not allow us to have a struct and a function with the same name we cannot have
Alternatively, and as a way to set up skipping It tests in a future PR, we can follow this pattern:
Changes made
Add the ability to skip all tests within a describe block if it was added using
g.Skip.Describe()
. The before and after hooks on a skipped test in thisSkip.Describe
block behave the same way asg.Xit()
tests - they do not run. Each Describe and It block within aSkip.Describe()
will be logged in yellow.Add a test for
g.Skip.Describe()
Alternatives considered:
Tried adding a new struct
Xdescribe
which holdsDescribe
. The issue I ran into when trying to implement this is that each It and Describe block currently has a.parent
field which references a*Describe
block. That would require a big refactor to convert every Describe and Xdescribe block to implement the same interface so that the.parent
in every It and Describe will refer to this interface likeRunnable()
. I am not completely clear if this will work, but looking for feedback if you guys think this is the preferred solution @marcosnils @xetorthio