agiledragon / gomonkey

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

是否有并发问题 #139

Closed xialonghua closed 8 months ago

xialonghua commented 8 months ago
  1. 对A方法插装A逻辑
  2. 单测
  3. reset
  4. 再次对A方法插装B逻辑
  5. 单测
  6. reset

当执行单测时5的单测会使用A逻辑,看着像并发问题?

agiledragon commented 8 months ago

A方法具有全局属性,打桩不是协程安全的,建议串行执行

xialonghua commented 8 months ago

A方法如果是某个实例的也不是协程安全的吗,如下 type IXXinterface { func A() } type XX struct {} func (x *XX) A(){}

agiledragon commented 8 months ago

方法是类属性,而不是实例属性

xialonghua commented 8 months ago

got it