agiledragon / gomonkey

gomonkey is a library to make monkey patching in unit tests easy
MIT License
1.92k stars 178 forks source link

TestApplyPrivateMethod run fail #119

Closed hesining closed 1 year ago

hesining commented 1 year ago

go version go1.19.5 linux/amd64

报错是:

Line 21: Expected: 'unhappy' Actual: 'happy' (Should be equal) goroutine 6 [running]: C:/Users/hesining/go/pkg/mod/github.com/smartystreets/goconvey@v1.6.4/convey/reporting/reports.go:143 +0x3c C:/Users/hesining/go/pkg/mod/github.com/smartystreets/goconvey@v1.6.4/convey/reporting/reports.go:103 +0x5d C:/Users/hesining/go/pkg/mod/github.com/smartystreets/goconvey@v1.6.4/convey/context.go:176 +0xa5 C:/Users/hesining/go/pkg/mod/github.com/smartystreets/goconvey@v1.6.4/convey/doc.go:125 +0x5a github.com/agiledragon/gomonkey/v2/test.TestApplyPrivateMethod.func1.1() D:/code/gomonkey-master/gomonkey-master/test/apply_private_method_test.go:21 +0x22e C:/Users/hesining/go/pkg/mod/github.com/smartystreets/goconvey@v1.6.4/convey/discovery.go:80 +0x1b C:/Users/hesining/go/pkg/mod/github.com/smartystreets/goconvey@v1.6.4/convey/context.go:261 +0x177 C:/Users/hesining/go/pkg/mod/github.com/smartystreets/goconvey@v1.6.4/convey/context.go:163 +0x2c github.com/jtolds/gls.(*ContextManager).SetValues.func1(0x0) C:/Users/hesining/go/pkg/mod/github.com/jtolds/gls@v4.20.0+incompatible/context.go:97 +0x46a github.com/jtolds/gls.EnsureGoroutineId(0xc00007c780) C:/Users/hesining/go/pkg/mod/github.com/jtolds/gls@v4.20.0+incompatible/gid.go:19 +0xfb github.com/jtolds/gls.(*ContextManager).SetValues(0xc000064590, 0xc00007c720, 0xc000010108) C:/Users/hesining/go/pkg/mod/github.com/jtolds/gls@v4.20.0+incompatible/context.go:63 +0x16a C:/Users/hesining/go/pkg/mod/github.com/smartystreets/goconvey@v1.6.4/convey/context.go:162 +0x2dc C:/Users/hesining/go/pkg/mod/github.com/smartystreets/goconvey@v1.6.4/convey/doc.go:77 +0x75 github.com/agiledragon/gomonkey/v2/test.TestApplyPrivateMethod.func1() D:/code/gomonkey-master/gomonkey-master/test/apply_private_method_test.go:13 +0x66 C:/Users/hesining/go/pkg/mod/github.com/smartystreets/goconvey@v1.6.4/convey/discovery.go:80 +0x1b C:/Users/hesining/go/pkg/mod/github.com/smartystreets/goconvey@v1.6.4/convey/context.go:261 +0x177 C:/Users/hesining/go/pkg/mod/github.com/smartystreets/goconvey@v1.6.4/convey/context.go:110 +0xdb github.com/jtolds/gls.(*ContextManager).SetValues.func1(0x0) C:/Users/hesining/go/pkg/mod/github.com/jtolds/gls@v4.20.0+incompatible/context.go:97 +0x46a github.com/jtolds/gls.EnsureGoroutineId.func1() C:/Users/hesining/go/pkg/mod/github.com/jtolds/gls@v4.20.0+incompatible/gid.go:24 +0x22 github.com/jtolds/gls._m(0x5e4540?, 0xc000048501?) C:/Users/hesining/go/pkg/mod/github.com/jtolds/gls@v4.20.0+incompatible/stack_tags.go:108 +0x22 github.com/jtolds/gls.github_com_jtolds_gls_markS(0xc00007c630?, 0x0?) C:/Users/hesining/go/pkg/mod/github.com/jtolds/gls@v4.20.0+incompatible/stack_tags.go:56 +0x19 github.com/jtolds/gls.addStackTag(...) C:/Users/hesining/go/pkg/mod/github.com/jtolds/gls@v4.20.0+incompatible/stack_tags.go:49 github.com/jtolds/gls.EnsureGoroutineId(0xc00007c630?) C:/Users/hesining/go/pkg/mod/github.com/jtolds/gls@v4.20.0+incompatible/gid.go:24 +0xd8 github.com/jtolds/gls.(*ContextManager).SetValues(0xc000064590, 0xc00007c5d0, 0xc0000660a0) C:/Users/hesining/go/pkg/mod/github.com/jtolds/gls@v4.20.0+incompatible/context.go:63 +0x16a C:/Users/hesining/go/pkg/mod/github.com/smartystreets/goconvey@v1.6.4/convey/context.go:105 +0x22f C:/Users/hesining/go/pkg/mod/github.com/smartystreets/goconvey@v1.6.4/convey/doc.go:75 +0x8b github.com/agiledragon/gomonkey/v2/test.TestApplyPrivateMethod(0x0?) D:/code/gomonkey-master/gomonkey-master/test/apply_private_method_test.go:12 +0x79 testing.tRunner(0xc000007a00, 0x6131c8) C:/Program Files/Go/src/testing/testing.go:1446 +0x10b created by testing.(*T).Run C:/Program Files/Go/src/testing/testing.go:1493 +0x35f

hesining commented 1 year ago

debug下正常,直接Run不正常