onsi / ginkgo

A Modern Testing Framework for Go
http://onsi.github.io/ginkgo/
MIT License
8.37k stars 660 forks source link

Suggestion for focused specs #13

Closed adamstep closed 11 years ago

adamstep commented 11 years ago

While using Ginkgo I find myself often using FDescribe() while implementing a feature, and then wanting to use FIt() within the block to debug a specific assertion:

FDescribe("some behavior", func() {
    FIt("some assertion", func(){ ... })
    It("some other assertion", func(){ ... })
})

However, go test runs all of the specs in the container, not just the focused one. This seems counter-intuitive to me.

If you agree that focused specs should take precedence over focused spec containers, I'd be happy to send a PR.

akitchen commented 11 years ago

It seems to me that you focused the whole container, which IMO should take precedence.

Many of our Cedar BDD projects use a script for removing focus from specs. Perhaps something like this would be useful here as well (to run when you have many focused specs to 'reset' the suite)

On Sat, Nov 16, 2013 at 2:41 PM, Adam Stepinski notifications@github.com wrote:

While using Ginkgo I find myself often using FDescribe() while implementing a feature, and then wanting to use FIt() within the block to debug a specific assertion:

FDescribe("some behavior", func() {
    FIt("some assertion", func(){ ... })
    It("some other assertion", func(){ ... })
})

However, go test runs all of the specs in the container, not just the focused one. This seems counter-intuitive to me.

If you agree that focused specs should take precedence over focused spec containers, I'd be happy to send a PR.

Reply to this email directly or view it on GitHub: https://github.com/onsi/ginkgo/issues/13

onsi commented 11 years ago

I think I agree with Andrew -- at some level this is somewhat subjective: should the outer focus take precedence or the inner focus? I went with the outer focus because it was easier to implement and because it matches the behavior of Cedar (which is one of the inspirations behind Ginkgo).

But I do think we're sorely lacking the "remove all focus" script. I'll add that to the ginkgo CLI soon.

onsi commented 11 years ago

I've updated the ginkgo cli -- running ginkgo unfocus removes any programmatically focused tests.

onsi commented 11 years ago

*I should say: it removes the focus from those tests, not the tests themselves!

adamstep commented 11 years ago

Awesome, this will definitely help my use case.