agiledragon / agiledragon/gomonkey

mock function affect other tests after Patches.Reset()

Open
#21 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
2.3k
Forks
192
Avg merge
1d 6h
Merged PRs (30d)
1

Description

func TestA(t *testing.T) {
Convey("TestA", t, func() {
Convey(" test1", func() {
Patches := ApplyFunc(**upgrade**, func(_ int ,_ uint) int{
return 10
})
defer Patches.Reset()
})
}
func **upgrade**(age int, num uint) int {
}

func TestB(t *testing.T){
Cover("TestB",t,func(){
res := **upgrade**(1,1) //it should be return 11 but affect by mock in **TestA**
So(res, ShouldEqual, 11)
})

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.