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 describe standalone #84

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

sockol
Copy link

@sockol sockol commented Apr 16, 2020

Motivations

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

  1. 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.

  2. 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

semur nabiev added 2 commits April 15, 2020 23:12
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()
@sockol sockol force-pushed the feature/skip-describe-standalone branch from afa2e4e to e7ca9ce Compare April 16, 2020 06:12
@sockol
Copy link
Author

sockol commented Apr 26, 2020

bumping this pr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant