-
-
Notifications
You must be signed in to change notification settings - Fork 645
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 hook the mock lib of testify into ginkgo? #17
Comments
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... So: step one would be to get a pull request into testify that replaces *testing.T with an interface (not hard from an implementation perspective, but it does add a layer of obfuscation into testify?) After that I should be able to cook up a testify module much like the go mock module. |
I have tried several mocking frameworks,such as gomock,mock of testify, mogo(https://github.com/gcurtis/mogo) that is quite like testify mock,and mock4go (https://github.com/jvshahid/mock4go).I found mock4go's approach is quite concise.So is it possible to integrate it to ginkgo?The last updates of mock4go has happened 7 month ago,but it doesn't matter,I will contact author,if he is busy or wants to quit, I can provide some help. |
Hey @AlexLuya: mogo looks like a slightly cleaner implementation than testify and would fit right into Ginkgo. One could even right a simple Gomega matcher to wrap calling the mock4go seems much more elaborate. in principal It Could Just Work... though it sounds like you have to run tests using Did you try using If you want my opinion: I generally prefer avoiding mocks/stubs entirely by writing my own fakes and injecting them into my objects under test. mogo sounds like a simple enough wrapper that allows you to write fakes with (a little) less code. IMHO mock4go goes a bit too far by instrumenting your production code. it probably doesn't break things.... but it is amending your code under the hood! |
I agree with this:"mock4go goes a bit too far by instrumenting your production code. it the hood!"And have report to author: jvshahid/mock4go#2 I will to try mogo with ginko. On 12/24/2013 04:18 AM, Onsi Fakhouri wrote:
|
This is now possible! See for an example of using testify with Ginkgo. |
@onsi correction on the link - http://onsi.github.io/ginkgo/#using-other-matcher-libraries |
feature: add tenant to request
* bugfix: loadconfig (onsi#17) feature: add tenant to request * WIP:add auth demo
* bugfix: loadconfig (onsi#17) feature: add tenant to request * WIP:add auth demo * bugfix: 修正API
* bugfix: loadconfig (onsi#17) feature: add tenant to request * WIP:add auth demo * add cargo preset
I think the mocking style of testify(https://github.com/stretchr/testify) is more nature than gomock,is it possible to hook it's mock lib into ginkgo?
The text was updated successfully, but these errors were encountered: