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

Is it possible to replace *testing.T with an interface? #27

Closed
AlexLuya opened this issue Nov 23, 2013 · 2 comments
Closed

Is it possible to replace *testing.T with an interface? #27

AlexLuya opened this issue Nov 23, 2013 · 2 comments

Comments

@AlexLuya
Copy link

I think the mocking style of testify is more nature than gomock,and hope it can be hooked into ginkgo(a BDD framework:https://github.com/onsi),so posted a function request here:onsi/ginkgo#17 the developer of ginkgo said:


It looks like testify uses (*testing.T) directly instead of an interface (which gomock does). Ginkgo can provide such frameworks with a Fail function that one can wrap in such a way to satisfy most interfaces (this is how we support go mock), but *testing.T refers to a concrete type and passing in the testing.T for the test that Ginkgo runs in would cause the entire suite to fail should one of your mock assertions fail...


His suggestion(or needing) is:replaces *testing.T with an interface first,so question:is it possible?.

@matryer
Copy link
Member

matryer commented Nov 23, 2013

I think that's possible - and might be worth doing. Especially since it won't break old code (since testing.T will always satisfy this new interface)

Perhaps you feel like doing it and sending in a pull request? As long as all the tests pass, we'll know it works.

Mat

Sent from my iPhone

On 22 Nov 2013, at 21:04, Alex Luya notifications@github.com wrote:

I think the mocking style of testify is more nature than gomock,and hope it can be hooked into ginkgo(a BDD framework:https://github.com/onsi),so posted a function request here:onsi/ginkgo#17 the developer of ginkgo said:

It looks like testify uses (*testing.T) directly instead of an interface (which gomock does). Ginkgo can provide such frameworks with a Fail function that one can wrap in such a way to satisfy most interfaces (this is how we support go mock), but *testing.T refers to a concrete type and passing in the testing.T for the test that Ginkgo runs in would cause the entire suite to fail should one of your mock assertions fail...

His suggestion(or needing) is:replaces *testing.T with an interface first,so question:is it possible?.


Reply to this email directly or view it on GitHub.

@matryer
Copy link
Member

matryer commented Jan 28, 2014

Done

@matryer matryer closed this as completed Jan 28, 2014
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

No branches or pull requests

2 participants