We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Current tests use gomonkey to setup and clear patches, which is not concurrent safe and does not always run well.
Here comes the new options: https://github.com/xhd2015/xgo.
If you like, I will later issue a PR to replace gomonkey, as did in this PR: kilianc/base-golang#3
The text was updated successfully, but these errors were encountered:
Could you describe more detail about the two repoes and why xgo is better?
Sorry, something went wrong.
Hi @Monokaix thanks for replying. Xgo and gomonkey can be compared as the following:
That's just a brief overview. Here is the API comparasion: gomonkey
gomonkey
import "github.com/agiledragon/gomonkey/v2" func greet(s string) string { return "hello "+s } func TestGreet(t *testing.T){ // patch is global, need to clear when current test ends gp:=gomonkey.NewPatches() defer gp.Reset() gp.ApplyFunc(greet, func(s string)string{ return "huh "+s }) result := greet("world") if result!="huh world"{ t.Fatalf("result: %s", result) } }
xgo
import "github.com/xhd2015/xgo/runtime/mock" func greet(s string) string { return "hello "+s } func TestGreet(t *testing.T){ // patch is local, automatically cleared when current test ends mock.Patch(greet, func(s string)string{ return "huh "+s }) result := greet("world") if result!="huh world"{ t.Fatalf("result: %s", result) } }
Besides the mock API, xgo has a builtin tool that can show the test execution trace:
xgo test --strace ./ xgo tool trace TestGreet.json
Would result a visual stack trace that helps debugging the tests easier, example from Shibbaz/GOEventBus#11
No branches or pull requests
Current tests use gomonkey to setup and clear patches, which is not concurrent safe and does not always run well.
Here comes the new options: https://github.com/xhd2015/xgo.
If you like, I will later issue a PR to replace gomonkey, as did in this PR: kilianc/base-golang#3
The text was updated successfully, but these errors were encountered: